From ca524fd37fc91e043c82ba10aed96f77d523c514 Mon Sep 17 00:00:00 2001 From: Matt Silverlock Date: Sat, 8 Aug 2015 12:41:49 +0800 Subject: [PATCH] Updated README w/ runnable example. Addresses #32. --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index e7566ca..bf49ebd 100644 --- a/README.md +++ b/README.md @@ -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.