add login form
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user