Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/athanclark/wai-middleware-verbs
Route to different middlewares based on the incoming HTTP verb detected.
https://github.com/athanclark/wai-middleware-verbs
haskell http-verbs wai-middleware
Last synced: 6 days ago
JSON representation
Route to different middlewares based on the incoming HTTP verb detected.
- Host: GitHub
- URL: https://github.com/athanclark/wai-middleware-verbs
- Owner: athanclark
- License: bsd-3-clause
- Created: 2015-09-22T20:02:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-22T17:08:50.000Z (almost 7 years ago)
- Last Synced: 2024-04-26T08:04:39.094Z (8 months ago)
- Topics: haskell, http-verbs, wai-middleware
- Language: Haskell
- Size: 28.3 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
wai-middleware-verbs
====================Route to different Wai middleware based on the incoming HTTP verb
detected.## Usage
This library depends on the [wai-transformers](https://hackage.haskell.org/package/wai-transformers)
package - we expect middleware to already be lifted to `MiddlewareT m`.As an example, here could be your application:
```haskell
import Network.Wai.Trans
import Network.Wai.Middleware.VerbsmyMid1 :: MiddlewareT (ReaderT Env m)
myMid2 :: MiddlewareuploadResponse :: ByteString -> MiddlewareT m
uploadResponse _ = liftMiddleware myMid2verbRoutes :: VerbListenerT (MiddlewareT m) m ()
verbRoutes = do
get myMid1
post uploadResponse
```Then, to use your newly assembled verb-router, turn the Verbs into a Middleware:
```haskell
verbMid :: MiddlewareT (ReaderT Env m)
verbMid = verbsToMiddleware verbRoutes
```From there, you can deconstruct your monolithic monad stack back down to `IO`,
and plug-it-in to your existing middleware.