From 4dbd1ced0d4060fd72f9c8c11209558925c64313 Mon Sep 17 00:00:00 2001 From: tom Date: Fri, 28 Feb 2025 13:09:15 +0100 Subject: [PATCH] CHANGE: added api endpoint for time path --- Backend/endpoints/time.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Backend/endpoints/time.go b/Backend/endpoints/time.go index 0e11a8e..4035e41 100644 --- a/Backend/endpoints/time.go +++ b/Backend/endpoints/time.go @@ -75,6 +75,12 @@ func getBookings(w http.ResponseWriter, r *http.Request) { http.Error(w, "Internal Server Error", http.StatusInternalServerError) 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) templates.TimePage(bookings).Render(ctx, w) }