# The route-generator package

[ Tags: program, utility ] [ Propose Tags ]

Most of the defacto Haskell web routing libraries are either linear in complexity, or require lots of extra extensions, like Template Haskell.

Luckily, yesod-routes has Yesod.Routes.Dispatch, which is a very clean, efficient, and extension-free router. Writing routes out in code can, however, be quite verbose. This utility is a code generator to produce routes compatible with Yesod.Routes.Dispatch from a nice input format.

Example:

GET /       => home
GET /post/: => showPost
PUT /*      => updateSomething
./routeGenerator routes.txt SomeModule

Will generate routes that map the correct HTTP verb (which you should pass as a prepended "path segment" to your Dispatch) and path to functions imported from the module specified in the second parameter.

A colon matches any path segment, and passes the matched segment through to the specified function, passing each match segment in order. The expected type of the segment is inferred from the type of the function. If the segment cannot be parsed as that type, the path does not match. Parsing is done with Web.PathPieces.fromPathPiece.

An asterisk at the end of the path causes rhHasMulti to be set to True, meaning that any path segments after what has been specified will be allowed.

## Properties

Versions 0.1, 0.2, 0.3, 0.3.1, 0.4, 0.5, 0.6, 0.6.1 attoparsec (>=0.10.0.0), base (==4.*), text (>=0.7), yesod-routes [details] OtherLicense © 2012 Stephen Paul Weber Stephen Paul Weber Stephen Paul Weber Utility http://github.com/singpolyma/route-generator http://github.com/singpolyma/route-generator/issues head: git clone git://github.com/route-generator/BitBrawl.git Thu Aug 9 03:02:22 UTC 2012 by StephenWeber NixOS:0.6.1 routeGenerator 1680 total (11 in the last 30 days) 0.0 (0 ratings) [clear rating] λ λ λ Docs not available Last success reported on 2015-10-19 Hackage Matrix CI

#### Maintainer's Corner

For package maintainers and hackage trustees

[back to package description]
Most of the defacto Haskell web routing libraries are either linear
in complexity, or require lots of extra extensions, like Template

Luckily, yesod-routes has Yesod.Routes.Dispatch, which is a very clean,
efficient, and extension-free router.  Writing routes out in code can,
however, be quite verbose.  This utility is a code generator to produce
routes compatible with Yesod.Routes.Dispatch from a nice input format.

Example:

> GET /       => home
> GET /post/: => showPost

> ./routeGenerator routes.txt SomeModule

Will generate routes that map the correct HTTP verb (which you should
pass as a prepended "path segment" to your Dispatch) and path to
functions imported from the module specified in the second parameter.

A colon matches any path segment, and passes the matched segment
through to the specified function, passing each match segment in order.
The expected type of the segment is inferred from the type of the
function.  If the segment cannot be parsed as that type, the path does
not match.  Parsing is done with Web.PathPieces.fromPathPiece.

An asterisk at the end of the path causes rhHasMulti to be set to True,
meaning that any path segments after what has been specified will be
allowed.