add login form

This commit is contained in:
2026-02-24 20:07:20 -05:00
parent 0d5cc4d21f
commit 2b6644e0a4
9 changed files with 122 additions and 32 deletions
+7 -3
View File
@@ -8,6 +8,7 @@ import (
"go-weather/middleware"
"go-weather/services"
"log"
"log/slog"
"net/http"
"os"
"os/signal"
@@ -49,6 +50,11 @@ func startPoller(db *sql.DB, ws *services.WeatherService, defaultCity string, in
}
func main() {
config := config.Load()
// Setup logger
var handler slog.Handler
handler = slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug})
slog.SetDefault(slog.New(handler))
// Connect to DB
connStr := fmt.Sprintf(
"host=%s port=%s user=%s password=%s dbname=%s sslmode=disable",
@@ -82,9 +88,7 @@ func main() {
http.HandlerFunc(weatherHandler.FetchWeather)),
)
http.Handle("/weather/me", middleware.AuthMiddleware(authService)(
http.HandlerFunc(userHandler.Me)),
)
http.Handle("/me", http.HandlerFunc(userHandler.Me))
http.HandleFunc("/weather/history", weatherHandler.GetHistory)
http.HandleFunc("/health", handlers.Health)