hyperbole-0.5.0: Interactive HTML apps using type-safe serverside Haskell
Safe HaskellSafe-Inferred
LanguageGHC2021

Web.Hyperbole.Effect.Response

Synopsis

Documentation

hyperView :: HyperView id es => id -> View id () -> Eff es Response Source #

Respond with the given hyperview

respondError :: Hyperbole :> es => ResponseError -> Eff es a Source #

Abort execution and respond with an error

respondErrorView :: Hyperbole :> es => Text -> View Body () -> Eff es a Source #

Abort execution and respond with an error view

notFound :: Hyperbole :> es => Eff es a Source #

Abort execution and respond with 404 Not Found

findUser :: (Hyperbole :> es, Users :> es) => Int -> Eff es User
findUser uid = do
  mu <- send (LoadUser uid)
  maybe notFound pure mu

userPage :: (Hyperbole :> es, Users :> es) => Page es '[]
userPage = do
  user <- findUser 100

  -- skipped if user not found
  pure $ userView user

parseError :: Hyperbole :> es => String -> Eff es a Source #

Respond immediately with a parse error

redirect :: Hyperbole :> es => URI -> Eff es a Source #

Abort execution and redirect to a URI

view :: View Body () -> Response Source #

Respond with a generic view. Normally you will return a view from the page or handler instead of using this function