Comments (2)
Hello,
I assume you've already seen the small sample. This library itself only does routing based on paths, with optional variable capture, which is usually the very first step in routing requests to handlers. Once a handler has been chosen based on the request path, you can perform additional routing / branching based on inspecting the request further. For example, to branch based on the request method, you can simply inspect the Request
passed to your handler function, e.g. extending the sample code:
bazHandler p rq k = case parseMethod (requestMethod rq) of
Right GET -> k $ responseLBS status200 []
$ maybe L.empty L.fromStrict (lookup "baz" p)
_ -> k $ responseLBS status405 [] L.empty
If your needs are basic, this approach can be sufficient. If you are interested in libraries that come with a lot more batteries included, you may be interested in one of scotty, wai-routing (which is built on top of this library) or servant but beware that the latter two employ some advanced features of Haskell's type system and may thus have a steep learning curve if you're just starting out.
from wai-route.
Thank you @romanb for your advice. I'll investigate wai-routing/Scotty
from wai-route.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wai-route.