diff options
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()) |
