Routing in Snap
In this recipe, we will add routes using the Snap Framework. We will add plain routes and routes with parameters.
How to do it...
- Create a new project,
routing-in-snap, with asimplestack template. We uselts-9.1as a resolver package archive. You can use the latest one available on Stackage. Just make sure that you use the sameresolverlater to solve the dependency constraints:
stack --resolver lts-9.1 new routing-in-snap simple
- Add a dependency on the following libraries in the
build-dependssubsection of theexecutablesection, as follows:
executable routing-in-snap
hs-source-dirs: src
main-is: Main.hs
default-language: Haskell2010
build-depends: base >= 4.7 && < 5
, snap-server
, snap-core
, snap
, lens
, bytestring
, text- Use the following command to...