Browse Source

Merge pull request #118 from elithrar/full-example

Updated README w/ runnable example. Addresses #32.
pull/119/head
Kamil Kisiel 11 years ago
parent
commit
ffb3f683aa
  1. 31
      README.md

31
README.md

@ -202,3 +202,34 @@ as well: @@ -202,3 +202,34 @@ as well:
url, err := r.Get("article").URL("subdomain", "news",
"category", "technology",
"id", "42")
## Full Example
Here's a complete, runnable example of a small mux based server:
```go
package main
import (
"net/http"
"github.com/gorilla/mux"
)
func YourHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Gorilla!\n"))
}
func main() {
r := mux.NewRouter()
// Routes consist of a path and a handler function.
r.HandleFunc("/", YourHandler)
// Bind to a port and pass our router in
http.ListenAndServe(":8000", r)
}
```
## License
BSD licensed. See the LICENSE file for details.

Loading…
Cancel
Save