diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-05-13 01:28:10 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-05-13 01:28:10 -0400 |
commit | d437b8911857199e53bd6cc449e17e0f3a583d0b (patch) | |
tree | 699273c4038fcedfb19a0ec73d7a4cea93aac2f5 | |
parent | 7d0b836693619d1fbe1da3b817e3820da6666699 (diff) | |
download | getwtxt-d437b8911857199e53bd6cc449e17e0f3a583d0b.tar.gz |
redundant path removed. comments added.
-rw-r--r-- | main.go | 8 |
1 files 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) |