Lucu-1.0: Embedded HTTP Server



Aborting the computation of Network.HTTP.Lucu.Rsrc in any IO monads.



data Abortion Source

Abortion is an Exception that aborts the execution of Network.HTTP.Lucu.Rsrc monad with a StatusCode, additional response headers, and an optional message text.

  1. If the Network.HTTP.Lucu.Rsrc is in the Deciding Header or any precedent states, throwing an Abortion affects the HTTP response to be sent to the client.
  2. Otherwise it's too late to overwrite the HTTP response so the only possible thing the system can do is to dump the exception to the stderr. See cnfDumpTooLateAbortionToStderr.

Note that the status code doesn't necessarily have to satisfy isError so you can abuse this exception for redirections as well as error reporting e.g.

   Network.HTTP.Lucu.abort $ Network.HTTP.Lucu.mkAbortion MovedPermanently
           [("Location", "")]
           (Just "It's been moved to")

mkAbortion :: (StatusCode sc, Foldable f (CIAscii, Ascii)) => sc -> f -> Maybe Text -> AbortionSource

Construct an Abortion with additional headers and an optional message text.

mkAbortion' :: StatusCode sc => sc -> Text -> AbortionSource

Construct an Abortion without any additional headers but with a message text.

abort :: MonadIO m => Abortion -> m aSource

Throw an Abortion in a MonadIO, including the very Network.HTTP.Lucu.Rsrc monad.