Пример #1
0
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)
}
Пример #2
0
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)
	}
}
Пример #3
0
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)

}