Skip to content

Instantly share code, notes, and snippets.

@bryanmikaelian
Last active December 15, 2015 09:19
Show Gist options
  • Save bryanmikaelian/5237575 to your computer and use it in GitHub Desktop.
Save bryanmikaelian/5237575 to your computer and use it in GitHub Desktop.
Mux and Go
package api
import (
"log"
"github.com/gorilla/mux"
"http"
)
func startRouter() {
r := mux.NewRouter()
r.HandleFunc("/", FooHandler)
http.ListenAndServe(":8080", nil)
}
func FooHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment