Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/singpolyma/route-generator
Utility to generate routes for use with yesod-routes
https://github.com/singpolyma/route-generator
Last synced: 3 months ago
JSON representation
Utility to generate routes for use with yesod-routes
- Host: GitHub
- URL: https://github.com/singpolyma/route-generator
- Owner: singpolyma
- License: isc
- Created: 2012-08-09T03:00:24.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-16T23:05:48.000Z (almost 11 years ago)
- Last Synced: 2024-09-17T01:38:32.010Z (4 months ago)
- Language: Haskell
- Homepage: http://hackage.haskell.org/package/route-generator
- Size: 186 KB
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: COPYING
Awesome Lists containing this project
README
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.