Skip to content
Snippets Groups Projects
Verified Commit f34d2ce3 authored by jan.hamal.dvorak's avatar jan.hamal.dvorak
Browse files

Remove wrapActions and wrapRoutes


There were kind of weird anyway.
I do not want to confuse users.

Signed-off-by: default avatarJan Hamal Dvořák <mordae@anilinux.org>
parent f035424c
No related branches found
No related tags found
No related merge requests found
...@@ -16,9 +16,7 @@ module Hikaru.Dispatch ...@@ -16,9 +16,7 @@ module Hikaru.Dispatch
-- ** Routes -- ** Routes
, route , route
, wrapRoute , wrapRoute
, wrapRoutes
, wrapAction , wrapAction
, wrapActions
-- ** Middleware -- ** Middleware
, middleware , middleware
...@@ -172,42 +170,25 @@ where ...@@ -172,42 +170,25 @@ where
in env { envRoutes = envRoutes env' <> envRoutes env } in env { envRoutes = envRoutes env' <> envRoutes env }
-- |
-- Wrap all /following/ routes with a route transformer.
--
wrapRoutes :: (Route r -> Route r) -> Dispatch r l ()
wrapRoutes wrapper = Dispatch do
modify \env -> env { envRouteW = envRouteW env . wrapper }
-- | -- |
-- Wrap all nested actions with an action transformer. -- Wrap all nested actions with an action transformer.
-- --
wrapAction :: (r -> r) -> Dispatch r Nested a -> Dispatch r l ()
wrapAction wrapper disp = Dispatch do
modify \env ->
let env' = execState (unDispatch disp)
(env { envActionW = envActionW env . wrapper })
in env { envRoutes = envRoutes env' <> envRoutes env }
-- |
-- Wrap all /following/ actions with an action transformer.
--
-- This can come in handy e.g. to tune cache control: -- This can come in handy e.g. to tune cache control:
-- --
-- @ -- @
-- app :: Application -- app :: Application
-- app = 'dispatch' runAction $ do -- app = 'dispatch' runAction $ do
-- 'wrapRoutes' ('Hikaru.Action.defaultHeader' hCacheControl "no-cache" >>) -- 'wrapAction' ('Hikaru.Action.defaultHeader' hCacheControl "no-cache" >>) $ do
-- -- 'route' $ getRootR \<$ 'get'
-- 'route' $ getRootR \<$ 'get' -- 'route' $ getHelloR \<$ 'get' <* 'seg' "hello" \<*\> 'arg'
-- 'route' $ getHelloR \<$ 'get' <* 'seg' "hello" \<*\> 'arg'
-- @ -- @
-- --
wrapActions :: (r -> r) -> Dispatch r l () wrapAction :: (r -> r) -> Dispatch r Nested a -> Dispatch r l ()
wrapActions wrapper = Dispatch do wrapAction wrapper disp = Dispatch do
modify \env -> env { envActionW = envActionW env . wrapper } modify \env ->
let env' = execState (unDispatch disp)
(env { envActionW = envActionW env . wrapper })
in env { envRoutes = envRoutes env' <> envRoutes env }
-- | -- |
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment