summary refs log tree commit diff stats
path: root/main.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-11 03:32:00 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-11 03:32:00 -0400
commitd4c05d21a4de2fe8f492957b66f40aa5e6757dca (patch)
tree620378cd1968cf31718c7ba1a03939f5411ac463 /main.go
parent474ffad421eee04a50cbdd5cfbc2b396c24dc521 (diff)
downloadgetwtxt-d4c05d21a4de2fe8f492957b66f40aa5e6757dca.tar.gz
skeleton handlers responding
Diffstat (limited to 'main.go')
-rw-r--r--main.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/main.go b/main.go
index 06d124a..d8a0614 100644
--- a/main.go
+++ b/main.go
@@ -8,17 +8,19 @@ import (
 	"github.com/gorilla/mux"
 )
 
+const getwtxt = "0.1"
+
 func main() {
-	log.Printf("getwtxt v0.1\n")
+	log.Printf("getwtxt " + getwtxt + "\n")
 
 	serv := mux.NewRouter()
 
 	serv.HandleFunc("/", indexHandler)
-	serv.HandleFunc("/api/", apiBaseHandler)
-	serv.HandleFunc("/api/{format:plain}", apiFormatHandler)
-	serv.HandleFunc("/api/{format:plain}/{endpoint:mentions|users|tweets}", apiEndpointHandler)
-	serv.HandleFunc("/api/{format:plain}/tags/{tags:[a-zA-Z0-9]+}", apiTagsHandler)
-	serv.HandleFunc("/api/{format:plain}/tags", apiTagsBaseHandler)
+	serv.HandleFunc("/{api:(?:api|api/)}", apiBaseHandler)
+	serv.HandleFunc("/api/{format:(?:plain|plain/)}", apiFormatHandler)
+	serv.HandleFunc("/api/{format:(?:plain)}/{endpoint:(?:mentions|mentions/|users|users/|tweets|tweets/)}", apiEndpointHandler)
+	serv.HandleFunc("/api/{format:(?:plain)}/tags/{tags:[a-zA-Z0-9]+}", apiTagsHandler)
+	serv.HandleFunc("/api/{format:(?:plain)}/{tagpathfixer:(?:tags|tags/)}", apiTagsBaseHandler)
 
 	log.Fatalln(http.ListenAndServe(":8080", handlers.CompressHandler(serv)))
 }