package main import ( "fmt" "github.com/gorilla/mux" "log" "net/http" "time" ) func RegexForHypha(s string) string { return s + ":[^\\s\\d:/?&\\\\][^:?&\\\\]*}" } func EditFillHandler(w http.ResponseWriter, r *http.Request) { } func HyphaHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) fmt.Fprintf(w, "Accessing hypha %v\n", vars["hypha"]) fmt.Fprintf(w, "Request at %v", r) } func main() { r := mux.NewRouter() r.Queries( "action", "edit", "fill", "{templateName}"). Path(RegexForHypha("/{hypha")). HandlerFunc(EditFillHandler) r.HandleFunc(RegexForHypha("/{hypha"), HyphaHandler) r.HandleFunc("/kek", HyphaHandler) http.Handle("/", r) srv := &http.Server{ Handler: r, Addr: "127.0.0.1:8000", // Good practice: enforce timeouts for servers you create! WriteTimeout: 15 * time.Second, ReadTimeout: 15 * time.Second, } log.Fatal(srv.ListenAndServe()) }