Skip to content

Commit

Permalink
chore: comment env
Browse files Browse the repository at this point in the history
  • Loading branch information
tomanagle committed Apr 2, 2024
1 parent aa9b0b8 commit 5054560
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
16 changes: 5 additions & 11 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,12 @@ import (
"github.com/go-chi/chi/v5/middleware"
)

/*
* Set to production at build time
* used to determine what assets to load
*/
var Environment = "development"

func TokenFromCookie(r *http.Request) string {
cookie, err := r.Cookie("access_token")
if err != nil {
return ""
}
return cookie.Value
}

func init() {
os.Setenv("env", Environment)
}
Expand All @@ -39,8 +35,6 @@ func main() {
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
r := chi.NewRouter()

logger.Info("Starting server", slog.String("environment", Environment))

cfg := config.MustLoadConfig()

db := database.MustOpen(cfg.DatabaseName)
Expand Down Expand Up @@ -118,7 +112,7 @@ func main() {
}
}()

logger.Info("Server started", slog.String("port", cfg.Port))
logger.Info("Server started", slog.String("port", cfg.Port), slog.String("env", Environment))
<-killSig

logger.Info("Shutting down server")
Expand Down
1 change: 0 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ type Config struct {
Port string `envconfig:"PORT" default:":4000"`
DatabaseName string `envconfig:"DATABASE_NAME" default:"goth.db"`
SessionCookieName string `envconfig:"SESSION_COOKIE_NAME" default:"session"`
Environment string `envconfig:"GO_ENV" default:"development"` // production or development
}

func loadConfig() (*Config, error) {
Expand Down

0 comments on commit 5054560

Please sign in to comment.