• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

example/H15-Aug-2017-

.gitignoreH A D15-Aug-201729

README.mdH A D15-Aug-20172.3 KiB

bench_test.goH A D15-Aug-2017330

mux.goH A D15-Aug-20177.9 KiB

mux_test.goH A D15-Aug-20177.6 KiB

README.md

1# pat (formerly pat.go) - A Sinatra style pattern muxer for Go's net/http library
2
3[![GoDoc](https://godoc.org/github.com/bmizerany/pat?status.svg)](https://godoc.org/github.com/bmizerany/pat)
4
5## INSTALL
6
7	$ go get github.com/bmizerany/pat
8
9## USE
10
11```go
12package main
13
14import (
15	"io"
16	"net/http"
17	"github.com/bmizerany/pat"
18	"log"
19)
20
21// hello world, the web server
22func HelloServer(w http.ResponseWriter, req *http.Request) {
23	io.WriteString(w, "hello, "+req.URL.Query().Get(":name")+"!\n")
24}
25
26func main() {
27	m := pat.New()
28	m.Get("/hello/:name", http.HandlerFunc(HelloServer))
29
30	// Register this pat with the default serve mux so that other packages
31	// may also be exported. (i.e. /debug/pprof/*)
32	http.Handle("/", m)
33	err := http.ListenAndServe(":12345", nil)
34	if err != nil {
35		log.Fatal("ListenAndServe: ", err)
36	}
37}
38```
39
40It's that simple.
41
42For more information, see:
43http://godoc.org/github.com/bmizerany/pat
44
45## CONTRIBUTORS
46
47* Alexis Svinartchouk (@zvin)
48* Blake Mizerany (@bmizerany)
49* Brian Ketelsen (@bketelsen)
50* Bryan Matsuo (@bmatsuo)
51* Caleb Spare (@cespare)
52* Evan Shaw (@edsrzf)
53* Gary Burd (@garyburd)
54* George Rogers (@georgerogers42)
55* Keith Rarick (@kr)
56* Matt Williams (@mattyw)
57* Mike Stipicevic (@wickedchicken)
58* Nick Saika (@nesv)
59* Timothy Cyrus (@tcyrus)
60* binqin (@binku87)
61
62## LICENSE
63
64Copyright (C) 2012 by Keith Rarick, Blake Mizerany
65
66Permission is hereby granted, free of charge, to any person obtaining a copy
67of this software and associated documentation files (the "Software"), to deal
68in the Software without restriction, including without limitation the rights
69to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
70copies of the Software, and to permit persons to whom the Software is
71furnished to do so, subject to the following conditions:
72
73The above copyright notice and this permission notice shall be included in
74all copies or substantial portions of the Software.
75
76THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
77IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
78FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
79AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
80LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
81OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
82THE SOFTWARE.
83