Skip to content

Commit

Permalink
📋 impl: Now the main package uses the router to initialize the applic…
Browse files Browse the repository at this point in the history
…ation's server!
  • Loading branch information
kevinmarquesp committed Jul 20, 2024
1 parent 3646536 commit 602f8db
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions cmd/go_postr/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
package main

import "fmt"
import (
"os"

"github.com/charmbracelet/log"
"github.com/joho/godotenv"

"github.com/kevinmarquesp/go-postr/internal/router"
)

const Dotenv = ".env"

func main() {
fmt.Println("Hello world!")
if err := godotenv.Load(Dotenv); err != nil {
log.Warn("Could not load the" + Dotenv + " file. Using the system's environment from now on...")
}

port := os.Getenv("PORT")
if port == "" {
log.Fatal("Required port variable was not found in the environment.")
}

log.Info("Starting the application at the port " + port + ".")

if err := router.StartRouter(port); err != nil {
log.Fatal("Router error.", "error", err)
}
}

0 comments on commit 602f8db

Please sign in to comment.