summary refs log tree commit diff stats
path: root/main.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-13 01:28:10 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-13 01:28:10 -0400
commitd437b8911857199e53bd6cc449e17e0f3a583d0b (patch)
tree699273c4038fcedfb19a0ec73d7a4cea93aac2f5 /main.go
parent7d0b836693619d1fbe1da3b817e3820da6666699 (diff)
downloadgetwtxt-d437b8911857199e53bd6cc449e17e0f3a583d0b.tar.gz
redundant path removed. comments added.
Diffstat (limited to 'main.go')
-rw-r--r--main.go8
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)