route-generator: Utility to generate routes for use with yesod-routes
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 -r -m SomeModule routes.txt
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.
[Skip to Readme]
Downloads
- route-generator-0.6.1.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1, 0.2, 0.3, 0.3.1, 0.4, 0.5, 0.6, 0.6.1 |
---|---|
Dependencies | attoparsec (>=0.10.0.0), base (>=4 && <5), network, text (>=0.7), yesod-routes [details] |
Tested with | ghc ==7.0.3 |
License | LicenseRef-OtherLicense |
Copyright | © 2012 Stephen Paul Weber |
Author | Stephen Paul Weber <singpolyma@singpolyma.net> |
Maintainer | Stephen Paul Weber <singpolyma@singpolyma.net> |
Category | Utility |
Home page | http://github.com/singpolyma/route-generator |
Bug tracker | http://github.com/singpolyma/route-generator/issues |
Source repo | head: git clone git://github.com/singpolyma/route-generator.git |
Uploaded | by StephenWeber at 2013-09-28T02:36:23Z |
Distributions | |
Reverse Dependencies | 1 direct, 0 indirect [details] |
Executables | routeGenerator |
Downloads | 5757 total (2 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs available [build log] Successful builds reported [all 1 reports] |