-
-
Save lfaoro/3a33a1a406ceba53f35403d1b1cd7491 to your computer and use it in GitHub Desktop.
A trial to use gorilla mux router Walk function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/gorilla/mux" | |
"net/http" | |
) | |
func signupHandler(w http.ResponseWriter, request *http.Request) { | |
fmt.Fprintf(w, "signup") | |
} | |
func play(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error { | |
fmt.Println(route.GetName()) | |
fmt.Println(route) | |
fmt.Println(router) | |
fmt.Println(ancestors) | |
return nil | |
} | |
func main() { | |
router := mux.NewRouter().StrictSlash(true) | |
router.HandleFunc("/control/dunno_flip/hola/hola", signupHandler) | |
router.HandleFunc("/control/db_stop/1/", signupHandler) | |
router.HandleFunc("/control/db_close/", signupHandler) | |
router.HandleFunc("/control/db_start/", signupHandler) | |
router.HandleFunc("/", signupHandler) | |
router.Walk(play) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment