Safe Haskell | None |
---|---|
Language | Haskell2010 |
Various functions for reading data from the current Spock Action's context. Currently that's just reading URL path info and auth data.
Synopsis
- getPath :: Has l lts v => FldProxy l -> TsActionCtxT lts xs sess v
- showPath :: (AllHave ToHttpApiData as, Has l lts v, v ~ Path as Open) => FldProxy l -> TsActionCtxT lts vec sess (HVectElim as Text)
- getExtra :: (MonadIO m, ListContains n v xs) => ActionCtxT (Context lts xs) m v
Documentation
getPath :: Has l lts v => FldProxy l -> TsActionCtxT lts xs sess v Source #
showPath :: (AllHave ToHttpApiData as, Has l lts v, v ~ Path as Open) => FldProxy l -> TsActionCtxT lts vec sess (HVectElim as Text) Source #
Look up a path and render it. This returns a sort-of variadic function that can be provided with the right number of arguments in order to render a path. As with the above example, a route like this:
runroute
ro rw $path
#user ("users" <//> var) (get
user)
could be rendered like this:
usersfn <- showPath #user let txt = usersfn "bob"
or, more succinctly:
txt <- ($ "bob") <$> showPath $user
getExtra :: (MonadIO m, ListContains n v xs) => ActionCtxT (Context lts xs) m v Source #
Look up data that was put into the ctxExtras
part of the action's
context. This is pretty bound up with type signatures and other verbosity,
but if we have a database-writing view like so:
runroute
ro rw $path
#rootroot
(dbwrite
$get
index)
then that index view could be written like so:
index ::ListContains
nReadWritePool
xs =>TsActionCtxT
lts xs sess a index = do db :: ReadWritePool <- getExtra ...