func init() { m := pat.New() m.Get("/hello/:name", http.HandlerFunc(HelloServer)) // Register this pat with the default serve mux so that other packages // may also be exported. (i.e. /debug/pprof/*) http.Handle("/", m) }
func main() { m := pat.New() m.Get("/hello/:name", http.HandlerFunc(HelloServer)) // Register this pat with the default serve mux so that other packages // may also be exported. (i.e. /debug/pprof/*) http.Handle("/", m) err := http.ListenAndServe(":12345", nil) if err != nil { log.Fatal("ListenAndServe: ", err) } }
func main() { // 4 CPUs on this machine. runtime.GOMAXPROCS(32) // "pat" allows params from url string mux := pat.New() mux.Post("/", http.HandlerFunc(handler.Post)) mux.Get("/:key", http.HandlerFunc(handler.Get)) http.Handle("/", mux) log.Println("Listening...") http.ListenAndServe(":3000", nil) }