hyperbole-0.4.2: Interactive HTML apps using type-safe serverside Haskell
Safe HaskellNone
LanguageGHC2021

Web.Hyperbole.Effect.Request

Synopsis

Documentation

request :: forall (es :: [Effect]). Hyperbole :> es => Eff es Request Source #

Return all information about the Request

reqPath :: forall (es :: [Effect]). Hyperbole :> es => Eff es [Segment] Source #

Return the request path

>>> reqPath
["users", "100"]

formBody :: forall (es :: [Effect]). Hyperbole :> es => Eff es Form Source #

Return the request body as a Web.FormUrlEncoded.Form

Prefer using Type-Safe Forms when possible

reqParams :: forall (es :: [Effect]). Hyperbole :> es => Eff es QueryText Source #

Return the entire Query

myPage :: Page es Response
myPage = do
  load $ do
    q <- reqParams
    case lookupParam "token" q of
      Nothing -> pure $ errorView "Missing Token in Query String"
      Just t -> do
        sideEffectUsingToken token
        pure myPageView

reqParam :: forall a (es :: [Effect]). (Hyperbole :> es, FromHttpApiData a) => Text -> Eff es a Source #

Require a given parameter from the Query arguments

myPage :: Page es Response
myPage = do
  load $ do
    token <- reqParam "token"
    sideEffectUsingToken token
    pure myPageView

lookupParam :: forall a (es :: [Effect]). (Hyperbole :> es, FromHttpApiData a) => Text -> Eff es (Maybe a) Source #

Maybe version of reqParam

myPage :: Page es Response
myPage = do
  load $ do
      mbToken <- lookupParam "token"
      sideEffectUsingToken $ fromMaybe "default" mbToken
      pure myPageView

hasParam :: Text -> QueryText -> Bool Source #

Whether the param is present or not