summary refs log tree commit diff stats
path: root/main.go
diff options
context:
space:
mode:
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)))
 }