URL router for golang webapps

Last week I've created an URL router and HandlerFunc dispatcher for go (golang) webapps.

I considered the following ideas (heavily borrowing from express/connect):

  • registering handlers based on HTTP verb/path combos should be easy, as this is most often used
  • split complex HandlerFuncs into multiple smaller one which can be shared
  • mount generic HandlerFuncs to be executed on every path
  • registering and accessing paths with params (like :userid) should be easy
  • store data on a requestContext, so it can be passed to later HandlerFuncs
  • set a generic errorHandlerFunc and stop executing later handerFuncs as soon as an error occurs
  • set a generic pageNotFound HandlerFunc
  • handlers are regular http.HandlerFunc to be compatible with go

I've created the package mainly to get my feet wet in go. A couple of similar packages already exist, but writing my own made me more familiar with the language and its standard lib.

The package is fully tested and ready to be used. Code can be found on github, documentation on godoc.