Skip to content

Instantly share code, notes, and snippets.

@vastbinderj
Created May 24, 2014 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vastbinderj/6dfc2e36ec82aa01d986 to your computer and use it in GitHub Desktop.
Save vastbinderj/6dfc2e36ec82aa01d986 to your computer and use it in GitHub Desktop.
negroni with httprouter
package main
import (
"fmt"
"net/http"
"github.com/codegangsta/negroni"
"github.com/julienschmidt/httprouter"
)
func main() {
// mux := http.NewServeMux()
// mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
// fmt.Fprintln(w, "Welcome to the homepage using http router")
// })
router := httprouter.New()
router.GET("/", func(w http.ResponseWriter, req *http.Request, _ map[string]string) {
fmt.Fprintln(w, "Welcome Home")
})
n := negroni.Classic()
//n.UseHandler(mux)
n.UseHandler(router)
n.Run(":8000")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment