package middleware import ( "marmic/servicetrade-toolbox/internal/api" "net/http" ) func AuthMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { cookie, err := r.Cookie("PHPSESSID") if err != nil { http.Redirect(w, r, "/login", http.StatusSeeOther) return } session := api.NewSession() session.Cookie = "PHPSESSID=" + cookie.Value // You might want to add a method to validate the session token // For now, we'll assume if the cookie exists, the session is valid next.ServeHTTP(w, r) }) }