This commit is contained in:
Mark McGranaghan
2012-09-19 22:54:00 -07:00
parent df39e7f534
commit 62d61b1b86
2 changed files with 19 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
package main
import ("net/http"; "github.com/bmizerany/pat"; "fmt")
func hello(w http.ResponseWriter, req *http.Request) {
fmt.Fprintln(w, "hello " + req.URL.Query().Get(":name"))
}
func main() {
p := pat.New()
p.Get("/hello/:name", http.HandlerFunc(hello))
http.ListenAndServe(":5000", p)
}
// == running
// $ go get github.com/bmizerany/pat
// $ go run xx-http-server-routing.go
//
// $ curl -i http://127.0.0.1:5000/hello/gopher