From 0154a152dd6d3606c9131f3186a9175ee5853185 Mon Sep 17 00:00:00 2001 From: Michael Hunteman Date: Sat, 28 Sep 2024 10:55:35 -0700 Subject: Use api endpoint for backend --- server/admin/handler.go | 2 +- server/cmd/main.go | 4 ++-- server/guest/handler.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'server') diff --git a/server/admin/handler.go b/server/admin/handler.go index fa2dfb4..0aa9659 100644 --- a/server/admin/handler.go +++ b/server/admin/handler.go @@ -34,7 +34,7 @@ func (adminHandler *AdminHandler) ServeHTTP(responseWriter http.ResponseWriter, switch { case request.Method == http.MethodOptions: responseWriter.WriteHeader(http.StatusOK) - case request.Method == http.MethodPost && request.URL.Path == "/admin/login": + case request.Method == http.MethodPost && request.URL.Path == "/api/admin/login": adminHandler.handleLogIn(responseWriter, request) default: responseWriter.WriteHeader(http.StatusNotFound) diff --git a/server/cmd/main.go b/server/cmd/main.go index 21cdccc..a180cc4 100644 --- a/server/cmd/main.go +++ b/server/cmd/main.go @@ -36,8 +36,8 @@ func main() { adminHandler := admin.NewAdminHandler(adminStore, guestStore) mux := http.NewServeMux() - mux.Handle("/guests/", guestHandler) - mux.Handle("/admin/", adminHandler) + mux.Handle("/api/guests/", guestHandler) + mux.Handle("/api/admin/", adminHandler) log.Fatal(http.ListenAndServe(":8080", serveHTTP(mux))) } diff --git a/server/guest/handler.go b/server/guest/handler.go index 008aeef..20ed2dc 100644 --- a/server/guest/handler.go +++ b/server/guest/handler.go @@ -13,8 +13,8 @@ import ( ) var ( - guestRegex = regexp.MustCompile(`^/guests/*$`) - guestIDRegex = regexp.MustCompile(`^/guests/([0-9]+)$`) + guestRegex = regexp.MustCompile(`^/api/guests/*$`) + guestIDRegex = regexp.MustCompile(`^/api/guests/([0-9]+)$`) ) type GuestHandler struct { @@ -46,7 +46,7 @@ func (handler *GuestHandler) ServeHTTP(responseWriter http.ResponseWriter, switch { case request.Method == http.MethodOptions: responseWriter.WriteHeader(http.StatusOK) - case request.Method == http.MethodPost && request.URL.Path == "/guests/login": + case request.Method == http.MethodPost && request.URL.Path == "/api/guests/login": handler.handleLogIn(responseWriter, request) case request.Method == http.MethodPut && guestIDRegex.MatchString(request.URL.Path): handler.handlePut(responseWriter, request) -- cgit v1.2.3