CHANGE: added api endpoint for time path

This commit is contained in:
2025-02-28 13:09:15 +01:00
parent 27bac5ff84
commit 4dbd1ced0d

View File

@@ -75,6 +75,12 @@ func getBookings(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Internal Server Error", http.StatusInternalServerError) http.Error(w, "Internal Server Error", http.StatusInternalServerError)
return return
} }
if r.Header.Get("Accept") == "application/json" {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(bookings)
return
}
ctx := context.WithValue(r.Context(), "user", user) ctx := context.WithValue(r.Context(), "user", user)
templates.TimePage(bookings).Render(ctx, w) templates.TimePage(bookings).Render(ctx, w)
} }