Created
          May 20, 2014 00:53 
        
      - 
      
- 
        Save jakejscott/ef21fdb774a2fe6d5c6b to your computer and use it in GitHub Desktop. 
    negroni + httprouter
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package main | |
| import ( | |
| "fmt" | |
| "github.com/codegangsta/negroni" | |
| "github.com/julienschmidt/httprouter" | |
| "net/http" | |
| ) | |
| 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 to the homepage using http router") | |
| }) | |
| n := negroni.Classic() | |
| //n.UseHandler(mux) | |
| n.UseHandler(router) | |
| n.Run(":9999") | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment