Last active
December 20, 2016 02:43
-
-
Save shiyanhui/b55fbec7799b2cb52385d1caf65cfad8 to your computer and use it in GitHub Desktop.
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
// Router implements http router. | |
type Router struct { | |
//... | |
} | |
// RegisterHandler registers handler to the router. | |
func (router *Router) RegisterHandler(method, path string, handler http.HandlerFunc) { | |
} | |
// Handler returns handler mapped to method and path. | |
func (router *Router) Handler(method, path string) http.HandlerFunc { | |
} | |
// ServeHTTP implements the interface http.Handler. | |
func (router *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { | |
} | |
func main() { | |
handler := func(w http.ResponseWriter, req *http.Request) { | |
fmt.Fprint(w, "hello world") | |
} | |
router := &Router{} | |
router.RegisterHandler("GET", "/", handler) | |
http.ListenAndServe(":8080", router) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment