Update structure to domain driven architecture.

This commit is contained in:
2026-05-08 08:14:25 +02:00
parent 4f3692abd9
commit 2993cc04ef
21 changed files with 185 additions and 103 deletions
+29
View File
@@ -0,0 +1,29 @@
package web
import (
"encoding/json"
"log"
"net/http"
)
// TODO CLEANUP: Test route for now
func (s *Server) handleHome() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// 1. Grab the userID from the context (placed there by s.hasAuth)
userID, ok := userIDFromContext(r.Context())
if !ok {
// Technically never happen if the middleware is working...
log.Printf("UNAUTHORIZED!")
http.Error(w, "User not found in context", http.StatusUnauthorized)
return
}
// 2. Respond with something that proves it works
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]interface{}{
"message": "Welcome to the nfeeder API!",
"user_id": userID,
"status": "authenticated",
})
}
}