From 39a926cd521806aedc298ddd671d1a118794fcec Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Wed, 17 Sep 2025 18:13:30 +0100 Subject: Add endpoints for web extension --- api/router.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'api/router.go') diff --git a/api/router.go b/api/router.go index 076beec..89abbc0 100644 --- a/api/router.go +++ b/api/router.go @@ -20,7 +20,14 @@ type ApiServices struct { func NewServer(api ApiServices) *http.ServeMux { mux := http.NewServeMux() - mux.HandleFunc("POST /record", middleware.Cors(handlers.RecordEntry(api.EntiresService, api.Config.Token))) + cors := middleware.PermissiveCors() + auth := middleware.MustAuthenticate(api.Config.Token) + + mux.HandleFunc("POST /record", cors(auth(handlers.RecordEntry(api.EntiresService)))) + mux.HandleFunc("PUT /record", cors(auth(handlers.UpdateEntry(api.EntiresService)))) + mux.HandleFunc("DELETE /record", cors(auth(handlers.DeleteEntry(api.EntiresService)))) + mux.HandleFunc("GET /entry", cors(auth(handlers.GetEntryURLs(api.EntiresService)))) + mux.HandleFunc("POST /entry", cors(auth(handlers.GetEntry(api.EntiresService)))) mux.HandleFunc("GET /html", handlers.GetEntriesHtml(api.EntiresService, api.HtmlService)) mux.HandleFunc("GET /", handlers.Pong()) -- cgit v1.2.3-70-g09d2