summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorMichael Hunteman <michael@huntm.net>2024-09-28 10:55:35 -0700
committerMichael Hunteman <michael@huntm.net>2024-09-28 11:25:16 -0700
commit0154a152dd6d3606c9131f3186a9175ee5853185 (patch)
treea166f0cf3819607592fb5ee03255108563f4ba68 /server
parent99b5a49b5fcccb7c6523a95c67e39830bc2a2a45 (diff)
Use api endpoint for backend
Diffstat (limited to 'server')
-rw-r--r--server/admin/handler.go2
-rw-r--r--server/cmd/main.go4
-rw-r--r--server/guest/handler.go6
3 files changed, 6 insertions, 6 deletions
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)