Add documentation

This commit is contained in:
sigma-andex 2022-06-05 20:12:57 +01:00
parent a7e1f4e309
commit f928e1b988
2 changed files with 7 additions and 0 deletions

View File

@ -6,5 +6,6 @@ import Prelude
import Control.Monad.Cont (ContT, runContT)
-- | Run the continuation
usingCont :: forall output m. Applicative m => ContT output m output -> m output
usingCont = flip runContT pure

View File

@ -47,9 +47,15 @@ fromJsonContinuation (JsonDecoder decode) errorHandler body handler = do
defaultErrorHandler :: forall (t47 :: Type) (m :: Type -> Type). MonadAff m => t47 -> m Response
defaultErrorHandler = const $ badRequest' jsonHeaders ""
-- | Parse the `RequestBody` as json using the provided `JsonDecoder`.
-- | If it fails, the error handler is called.
-- | Returns a continuation
fromJsonE :: forall (err :: Type) (json :: Type). JsonDecoder err json -> (err -> ResponseM) -> RequestBody -> ContT Response Aff json
fromJsonE driver errorHandler body = ContT $ (fromJsonContinuation driver errorHandler body)
-- | Parse the `RequestBody` as json using the provided `JsonDecoder`.
-- | If it fails, an empty bad request is returned
-- | Returns a continuation
fromJson :: forall (err :: Type) (json :: Type). JsonDecoder err json -> RequestBody -> ContT Response Aff json
fromJson driver = fromJsonE driver defaultErrorHandler