Cleaned Up Logging And Variables

This commit is contained in:
Annika Merris 2024-02-10 17:27:08 -05:00
parent b5ea01729b
commit f483833260

View file

@ -3,7 +3,6 @@ package main
import ( import (
"context" "context"
"fmt" "fmt"
"log"
"log/slog" "log/slog"
"net/http" "net/http"
"os" "os"
@ -18,7 +17,6 @@ import (
"github.com/go-chi/cors" "github.com/go-chi/cors"
"github.com/go-chi/httplog/v2" "github.com/go-chi/httplog/v2"
"github.com/jackc/pgx/v4/pgxpool" "github.com/jackc/pgx/v4/pgxpool"
"github.com/lestrrat-go/jwx/v2/jwk"
"github.com/lmittmann/tint" "github.com/lmittmann/tint"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
@ -48,9 +46,9 @@ func main() {
deps := dependencies{} deps := dependencies{}
deps.initializeDependencies() deps.initializeDependencies()
fmt.Printf("Preparing to listen on `:%v`\n", conf.HttpPort) logger.Info(fmt.Sprintf("Preparing to listen on `:%v`", conf.HttpPort))
err := http.ListenAndServe(fmt.Sprintf(":%v", conf.HttpPort), deps.router) err := http.ListenAndServe(fmt.Sprintf(":%v", conf.HttpPort), deps.router)
log.Fatal(err) logger.Error("Error starting server", "error", err)
} }
func setupConfig() { func setupConfig() {
@ -78,11 +76,9 @@ type dependencies struct {
router *chi.Mux router *chi.Mux
postgresConnection *pgxpool.Pool postgresConnection *pgxpool.Pool
context context.Context context context.Context
jwkContext context.Context
powerItemQuerier *powerItem.DBQuerier powerItemQuerier *powerItem.DBQuerier
powerItemService *services.PowerItemService powerItemService *services.PowerItemService
powerItemController *controllers.PowerItemController powerItemController *controllers.PowerItemController
jwkCache *jwk.Cache
} }
func (d *dependencies) initializeDependencies() error { func (d *dependencies) initializeDependencies() error {