Created
January 11, 2016 00:51
-
-
Save elico/170b4d98b52b1da58d56 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