Skip to content

Fork of julienschmidt/httprouter that uses regular http.HandlerFunc handlers.

License

Notifications You must be signed in to change notification settings

mdevan/httprouter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a fork of github.com/julienschmidt/httprouter, with one single, API-breaking change: the handler functions are of the type http.HandlerFunc rather than httprouter.Handle.

This is how a handler function would be defined in the original httprouter:

import "github.com/julienschmidt/httprouter"

func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
    fmt.Fprintf(w, "hello, %s!\n", ps.ByName("name"))
}

And here is the same in the new one:

import "github.com/mdevan/httprouter"

func Hello(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "hello, %s!\n", httprouter.Param(r, "name"))
}

Under the hood, the params are stored in the context attached to http.Request.

There are no other changes.

For docs and everything else, please refer https://github.com/julienschmidt/httprouter. The auto-generated API doc is available at http://godoc.org/github.com/mdevan/httprouter.

About

Fork of julienschmidt/httprouter that uses regular http.HandlerFunc handlers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%