diff options
| author | Leonardo Bishop <me@leonardobishop.net> | 2025-09-17 18:13:30 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.net> | 2025-09-17 18:13:30 +0100 |
| commit | 39a926cd521806aedc298ddd671d1a118794fcec (patch) | |
| tree | a38908af8c91e01b2acec112b871c951e1bf6c1b /api/router.go | |
| parent | 1b7c07d9bbfb7984536a3aeade0f543251f1a666 (diff) | |
Add endpoints for web extension
Diffstat (limited to 'api/router.go')
| -rw-r--r-- | api/router.go | 9 |
1 files changed, 8 insertions, 1 deletions
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()) |
