From d437b8911857199e53bd6cc449e17e0f3a583d0b Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Mon, 13 May 2019 01:28:10 -0400 Subject: redundant path removed. comments added. --- main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 25d95af..bca7847 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,9 @@ const getwtxt = "0.1" func main() { + // StrictSlash(true) allows /api and /api/ + // to serve the same content without duplicating + // handlers/paths index := mux.NewRouter().StrictSlash(true) api := index.PathPrefix("/api").Subrouter() @@ -24,9 +27,6 @@ func main() { index.Path("/api"). Methods("GET"). HandlerFunc(apiBaseHandler) - api.Path("/"). - Methods("GET"). - HandlerFunc(apiBaseHandler) // twtxt will add support for other formats later. // Maybe json? Making this future-proof. api.Path("/{format:(?:plain)}"). @@ -48,9 +48,11 @@ func main() { Queries("url", "{url}", "nickname", "{nickname:[a-zA-Z0-9]+}"). Methods("POST"). HandlerFunc(apiEndpointPOSTHandler) + // Show all observed tags api.Path("/{format:(?:plain)}/tags"). Methods("GET"). HandlerFunc(apiTagsBaseHandler) + // Requests tweets with a specific tag api.Path("/{format:(?:plain)}/tags/{tags:[a-zA-Z0-9]+}"). Methods("GET"). HandlerFunc(apiTagsHandler) -- cgit 1.4.1-2-gfad0