-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Another Haskell web framework for rapid development
--   
--   Barebones high performance type safe web framework
@package Spock-core
@version 0.12.0.0

module Web.Spock.Internal.Cookies

-- | Cookie settings
data CookieSettings
CookieSettings :: CookieEOL -> Maybe ByteString -> Maybe ByteString -> Bool -> Bool -> CookieSettings

-- | cookie expiration setting, see <a>CookieEOL</a>
[cs_EOL] :: CookieSettings -> CookieEOL

-- | a path for the cookie
[cs_path] :: CookieSettings -> Maybe ByteString

-- | a domain for the cookie. <a>Nothing</a> means no domain is set
[cs_domain] :: CookieSettings -> Maybe ByteString

-- | whether the cookie should be set as HttpOnly
[cs_HTTPOnly] :: CookieSettings -> Bool

-- | whether the cookie should be marked secure (sent over HTTPS only)
[cs_secure] :: CookieSettings -> Bool

-- | Setting cookie expiration
data CookieEOL

-- | a point in time in UTC until the cookie is valid
CookieValidUntil :: UTCTime -> CookieEOL

-- | a period (in seconds) for which the cookie is valid
CookieValidFor :: NominalDiffTime -> CookieEOL

-- | the cookie expires with the browser session
CookieValidForSession :: CookieEOL

-- | the cookie will have an expiration date in the far future
CookieValidForever :: CookieEOL

-- | Default cookie settings, equals
--   
--   <pre>
--   CookieSettings
--     { cs_EOL      = CookieValidForSession
--     , cs_HTTPOnly = False
--     , cs_secure   = False
--     , cs_domain   = Nothing
--     , cs_path     = Just "/"
--     }
--   </pre>
defaultCookieSettings :: CookieSettings
parseCookies :: ByteString -> [(Text, Text)]
generateCookieHeaderString :: Text -> Text -> CookieSettings -> UTCTime -> ByteString
renderCookie :: SetCookie -> ByteString

module Web.Spock.Internal.Util
data ClientPreferredFormat
PrefJSON :: ClientPreferredFormat
PrefXML :: ClientPreferredFormat
PrefHTML :: ClientPreferredFormat
PrefText :: ClientPreferredFormat
PrefUnknown :: ClientPreferredFormat
mimeMapping :: HashMap Text ClientPreferredFormat
detectPreferredFormat :: Text -> ClientPreferredFormat
mapReqHeaders :: (ResponseHeaders -> ResponseHeaders) -> Response -> Response
instance GHC.Classes.Eq Web.Spock.Internal.Util.ClientPreferredFormat
instance GHC.Show.Show Web.Spock.Internal.Util.ClientPreferredFormat

module Web.Spock.Action
type ActionT = ActionCtxT ()
data ActionCtxT ctx m a

-- | Get the original Wai Request object
request :: MonadIO m => ActionCtxT ctx m Request

-- | Read a header
header :: MonadIO m => Text -> ActionCtxT ctx m (Maybe Text)

-- | Read a header without converting it to text
rawHeader :: MonadIO m => HeaderName -> ActionCtxT ctx m (Maybe ByteString)

-- | Read all cookies. The cookie value will already be urldecoded.
cookies :: MonadIO m => ActionCtxT ctx m [(Text, Text)]

-- | Read a cookie. The cookie value will already be urldecoded. Note that
--   it is more efficient to use <a>cookies</a> if you need do access many
--   cookies during a request handler.
cookie :: MonadIO m => Text -> ActionCtxT ctx m (Maybe Text)

-- | Returns the current request method, e.g. <tt>GET</tt>
reqMethod :: MonadIO m => ActionCtxT ctx m SpockMethod

-- | Tries to dected the preferred format of the response using the Accept
--   header
preferredFormat :: MonadIO m => ActionCtxT ctx m ClientPreferredFormat
data ClientPreferredFormat
PrefJSON :: ClientPreferredFormat
PrefXML :: ClientPreferredFormat
PrefHTML :: ClientPreferredFormat
PrefText :: ClientPreferredFormat
PrefUnknown :: ClientPreferredFormat

-- | Get the raw request body
body :: MonadIO m => ActionCtxT ctx m ByteString

-- | Parse the request body as json
jsonBody :: (MonadIO m, FromJSON a) => ActionCtxT ctx m (Maybe a)

-- | Parse the request body as json and fails with 400 status code on error
jsonBody' :: (MonadIO m, FromJSON a) => ActionCtxT ctx m a

-- | Get uploaded files
files :: MonadIO m => ActionCtxT ctx m (HashMap Text UploadedFile)
data UploadedFile
UploadedFile :: !Text -> !Text -> !FilePath -> UploadedFile
[uf_name] :: UploadedFile -> !Text
[uf_contentType] :: UploadedFile -> !Text
[uf_tempLocation] :: UploadedFile -> !FilePath

-- | Get all request (POST + GET) params
params :: MonadIO m => ActionCtxT ctx m [(Text, Text)]

-- | Get all request GET params
paramsGet :: MonadIO m => ActionCtxT ctx m [(Text, Text)]

-- | Get all request POST params
paramsPost :: MonadIO m => ActionCtxT ctx m [(Text, Text)]

-- | Read a request param. Spock looks POST variables first and then in GET
--   variables
param :: (FromHttpApiData p, MonadIO m) => Text -> ActionCtxT ctx m (Maybe p)

-- | Like <a>param</a>, but outputs an error when a param is missing
param' :: (FromHttpApiData p, MonadIO m) => Text -> ActionCtxT ctx m p

-- | Get the context of the current request
getContext :: MonadIO m => ActionCtxT ctx m ctx

-- | Run an Action in a different context
runInContext :: MonadIO m => ctx' -> ActionCtxT ctx' m a -> ActionCtxT ctx m a

-- | Set a response status
setStatus :: MonadIO m => Status -> ActionCtxT ctx m ()

-- | Set a response header. If the response header is allowed to occur
--   multiple times (as in RFC 2616), it will be appended. Otherwise the
--   previous value is overwritten. See <a>setMultiHeader</a>.
setHeader :: MonadIO m => Text -> Text -> ActionCtxT ctx m ()

-- | Redirect to a given url
redirect :: MonadIO m => Text -> ActionCtxT ctx m a

-- | Abort the current action and jump the next one matching the route
jumpNext :: MonadIO m => ActionCtxT ctx m a

-- | Cookie settings
data CookieSettings
CookieSettings :: CookieEOL -> Maybe ByteString -> Maybe ByteString -> Bool -> Bool -> CookieSettings

-- | cookie expiration setting, see <a>CookieEOL</a>
[cs_EOL] :: CookieSettings -> CookieEOL

-- | a path for the cookie
[cs_path] :: CookieSettings -> Maybe ByteString

-- | a domain for the cookie. <a>Nothing</a> means no domain is set
[cs_domain] :: CookieSettings -> Maybe ByteString

-- | whether the cookie should be set as HttpOnly
[cs_HTTPOnly] :: CookieSettings -> Bool

-- | whether the cookie should be marked secure (sent over HTTPS only)
[cs_secure] :: CookieSettings -> Bool

-- | Default cookie settings, equals
--   
--   <pre>
--   CookieSettings
--     { cs_EOL      = CookieValidForSession
--     , cs_HTTPOnly = False
--     , cs_secure   = False
--     , cs_domain   = Nothing
--     , cs_path     = Just "/"
--     }
--   </pre>
defaultCookieSettings :: CookieSettings

-- | Setting cookie expiration
data CookieEOL

-- | a point in time in UTC until the cookie is valid
CookieValidUntil :: UTCTime -> CookieEOL

-- | a period (in seconds) for which the cookie is valid
CookieValidFor :: NominalDiffTime -> CookieEOL

-- | the cookie expires with the browser session
CookieValidForSession :: CookieEOL

-- | the cookie will have an expiration date in the far future
CookieValidForever :: CookieEOL

-- | Set a cookie. The cookie value will be urlencoded.
setCookie :: MonadIO m => Text -> Text -> CookieSettings -> ActionCtxT ctx m ()

-- | Delete a cookie
deleteCookie :: MonadIO m => Text -> ActionCtxT ctx m ()

-- | Send a <tt>ByteString</tt> as response body. Provide your own
--   <a>Content-Type</a>
bytes :: MonadIO m => ByteString -> ActionCtxT ctx m a

-- | Send a lazy <tt>ByteString</tt> as response body. Provide your own
--   <a>Content-Type</a>
lazyBytes :: MonadIO m => ByteString -> ActionCtxT ctx m a

-- | Set a response header that can occur multiple times. (eg:
--   Cache-Control)
setRawMultiHeader :: MonadIO m => MultiHeader -> ByteString -> ActionCtxT ctx m ()
data MultiHeader
MultiHeaderCacheControl :: MultiHeader
MultiHeaderConnection :: MultiHeader
MultiHeaderContentEncoding :: MultiHeader
MultiHeaderContentLanguage :: MultiHeader
MultiHeaderPragma :: MultiHeader
MultiHeaderProxyAuthenticate :: MultiHeader
MultiHeaderTrailer :: MultiHeader
MultiHeaderTransferEncoding :: MultiHeader
MultiHeaderUpgrade :: MultiHeader
MultiHeaderVia :: MultiHeader
MultiHeaderWarning :: MultiHeader
MultiHeaderWWWAuth :: MultiHeader
MultiHeaderSetCookie :: MultiHeader

-- | Send text as a response body. Content-Type will be "text/plain"
text :: MonadIO m => Text -> ActionCtxT ctx m a

-- | Send a text as response body. Content-Type will be "text/html"
html :: MonadIO m => Text -> ActionCtxT ctx m a

-- | Send a file as response
file :: MonadIO m => Text -> FilePath -> ActionCtxT ctx m a

-- | Send json as response. Content-Type will be "application/json"
json :: (ToJSON a, MonadIO m) => a -> ActionCtxT ctx m b

-- | Use a <a>StreamingBody</a> to generate a response.
stream :: MonadIO m => StreamingBody -> ActionCtxT ctx m a

-- | Use a custom <a>Response</a> generator as response body.
response :: MonadIO m => (Status -> ResponseHeaders -> Response) -> ActionCtxT ctx m a

-- | Respond to the request by running an <a>Application</a>. This is
--   usefull in combination with wildcard routes. This can not be used in
--   combination with other request consuming combinators like
--   <a>jsonBody</a>, <a>body</a>, <a>paramsPost</a>, ...
respondApp :: Monad m => Application -> ActionCtxT ctx m a

-- | Respond to the request by running a <a>Middleware</a>. This is usefull
--   in combination with wildcard routes. This can not be used in
--   combination with other request consuming combinators like
--   <a>jsonBody</a>, <a>body</a>, <a>paramsPost</a>, ...
respondMiddleware :: Monad m => Middleware -> ActionCtxT ctx m a

-- | If the Spock application is used as a middleware, you can use this to
--   pass request handling to the underlying application. If Spock is not
--   uses as a middleware, or there is no underlying application this will
--   result in 404 error.
middlewarePass :: MonadIO m => ActionCtxT ctx m a

-- | Modify the vault (useful for sharing data between middleware and app)
modifyVault :: MonadIO m => (Vault -> Vault) -> ActionCtxT ctx m ()

-- | Query the vault
queryVault :: MonadIO m => Key a -> ActionCtxT ctx m (Maybe a)

-- | Convenience Basic authentification provide a title for the prompt and
--   a function to validate user and password. Usage example:
--   
--   <pre>
--   get ("auth" &lt;//&gt; var &lt;//&gt; var) $ \user pass -&gt;
--         let checker user' pass' =
--                 unless (user == user' &amp;&amp; pass == pass') $
--                 do setStatus status401
--                    text "err"
--         in requireBasicAuth "Foo" checker $ \() -&gt; text "ok"
--   </pre>
requireBasicAuth :: MonadIO m => Text -> (Text -> Text -> ActionCtxT ctx m b) -> (b -> ActionCtxT ctx m a) -> ActionCtxT ctx m a

-- | "Lower level" basic authentification handeling. Does not set any
--   headers that will promt browser users, only looks for an
--   <a>Authorization</a> header in the request and breaks it into username
--   and passwort component if present
withBasicAuthData :: MonadIO m => (Maybe (Text, Text) -> ActionCtxT ctx m a) -> ActionCtxT ctx m a

module Web.Spock.Routing
class RouteM t
addMiddleware :: (RouteM t, Monad m) => Middleware -> t ctx m ()
inSubcomponent :: (RouteM t, Monad m) => Path '[]  'Open -> t ctx m () -> t ctx m ()
withPrehook :: (RouteM t, MonadIO m) => ActionCtxT ctx m ctx' -> t ctx' m () -> t ctx m ()
wireAny :: (RouteM t, Monad m) => SpockMethod -> ([Text] -> ActionCtxT ctx m ()) -> t ctx m ()
wireRoute :: (RouteM t, Monad m, HasRep xs) => SpockMethod -> Path xs ps -> HVectElim xs (ActionCtxT ctx m ()) -> t ctx m ()

module Web.Spock.Core

-- | Run a Spock application. Basically just a wrapper around <a>run</a>.
runSpock :: Port -> IO Middleware -> IO ()

-- | Like <a>runSpock</a>, but does not display the banner "Spock is
--   running on port XXX" on stdout.
runSpockNoBanner :: Port -> IO Middleware -> IO ()

-- | Convert a middleware to an application. All failing requests will
--   result in a 404 page
spockAsApp :: IO Middleware -> IO Application

-- | Create a raw spock application with custom underlying monad Use
--   <a>runSpock</a> to run the app or <a>spockAsApp</a> to create a
--   <tt>Wai.Application</tt> The first argument is request size limit in
--   bytes. Set to <a>Nothing</a> to disable.
spockT :: (MonadIO m) => (forall a. m a -> IO a) -> SpockT m () -> IO Middleware

-- | Like <a>spockT</a>, but first argument is request size limit in bytes.
--   Set to <a>Nothing</a> to disable.

-- | <i>Deprecated: Consider using spockConfigT instead</i>
spockLimT :: forall m. MonadIO m => Maybe Word64 -> (forall a. m a -> IO a) -> SpockT m () -> IO Middleware

-- | Like <a>spockT</a>, but with additional configuration for request size
--   and error handlers passed as first parameter.
spockConfigT :: forall m. MonadIO m => SpockConfig -> (forall a. m a -> IO a) -> SpockT m () -> IO Middleware
type SpockT = SpockCtxT ()
data SpockCtxT ctx m a
data Path (as :: [*]) (pathState :: PathState) :: [*] -> PathState -> *

-- | The root of a path piece. Use to define a handler for "/"
root :: Path [] * Open
type Var a = Path (:) * a [] * Open

-- | A route parameter
var :: (Typeable * a, FromHttpApiData a) => Path (:) * a [] * Open

-- | A static route piece
static :: String -> Path [] * Open

-- | Combine two path components
(<//>) :: Path as  'Open -> Path bs ps -> Path (Append as bs) ps

-- | Matches the rest of the route. Should be the last part of the path.
wildcard :: Path (:) * Text [] * Closed

-- | Render a route applying path pieces
renderRoute :: AllHave ToHttpApiData as => Path as  'Open -> HVectElim as Text

-- | Define a subcomponent. Usage example:
--   
--   <pre>
--   subcomponent "site" $
--     do get "home" homeHandler
--        get ("misc" &lt;//&gt; var) $ -- ...
--   subcomponent "admin" $
--     do get "home" adminHomeHandler
--   </pre>
--   
--   The request /site/home will be routed to homeHandler and the request
--   /admin/home will be routed to adminHomeHandler

-- | <i>Deprecated: Subcomponents will be removed in the next major
--   release. They break route rendering and should not be used. Consider
--   creating helper functions for reusable route components</i>
subcomponent :: (RouteM t, Monad m) => Path '[]  'Open -> t ctx m () -> t ctx m ()

-- | Specify an action that will be run before all subroutes. It can modify
--   the requests current context
prehook :: (RouteM t, MonadIO m) => ActionCtxT ctx m ctx' -> t ctx' m () -> t ctx m ()

-- | Specify an action that will be run when the HTTP verb <a>GET</a> and
--   the given route match
get :: (HasRep xs, RouteM t, Monad m) => Path xs ps -> HVectElim xs (ActionCtxT ctx m ()) -> t ctx m ()

-- | Specify an action that will be run when the HTTP verb <a>POST</a> and
--   the given route match
post :: (HasRep xs, RouteM t, Monad m) => Path xs ps -> HVectElim xs (ActionCtxT ctx m ()) -> t ctx m ()

-- | Specify an action that will be run when the HTTP verb 'GET'/'POST' and
--   the given route match
getpost :: (HasRep xs, RouteM t, Monad m, Monad (t ctx m)) => Path xs ps -> HVectElim xs (ActionCtxT ctx m ()) -> t ctx m ()

-- | Specify an action that will be run when the HTTP verb <a>HEAD</a> and
--   the given route match
head :: (HasRep xs, RouteM t, Monad m) => Path xs ps -> HVectElim xs (ActionCtxT ctx m ()) -> t ctx m ()

-- | Specify an action that will be run when the HTTP verb <a>PUT</a> and
--   the given route match
put :: (HasRep xs, RouteM t, Monad m) => Path xs ps -> HVectElim xs (ActionCtxT ctx m ()) -> t ctx m ()

-- | Specify an action that will be run when the HTTP verb <a>DELETE</a>
--   and the given route match
delete :: (HasRep xs, RouteM t, Monad m) => Path xs ps -> HVectElim xs (ActionCtxT ctx m ()) -> t ctx m ()

-- | Specify an action that will be run when the HTTP verb <a>PATCH</a> and
--   the given route match
patch :: (HasRep xs, RouteM t, Monad m) => Path xs ps -> HVectElim xs (ActionCtxT ctx m ()) -> t ctx m ()

-- | Specify an action that will be run when a standard HTTP verb and the
--   given route match
hookRoute :: (HasRep xs, RouteM t, Monad m) => StdMethod -> Path xs ps -> HVectElim xs (ActionCtxT ctx m ()) -> t ctx m ()

-- | Specify an action that will be run when a custom HTTP verb and the
--   given route match
hookRouteCustom :: (HasRep xs, RouteM t, Monad m) => Text -> Path xs ps -> HVectElim xs (ActionCtxT ctx m ()) -> t ctx m ()

-- | Specify an action that will be run when a standard HTTP verb matches
--   but no defined route matches. The full path is passed as an argument
hookAny :: (RouteM t, Monad m) => StdMethod -> ([Text] -> ActionCtxT ctx m ()) -> t ctx m ()

-- | Specify an action that will be run when a custom HTTP verb matches but
--   no defined route matches. The full path is passed as an argument
hookAnyCustom :: (RouteM t, Monad m) => Text -> ([Text] -> ActionCtxT ctx m ()) -> t ctx m ()

-- | HTTP standard method (as defined by RFC 2616, and PATCH which is
--   defined by RFC 5789).
data StdMethod :: *
GET :: StdMethod
POST :: StdMethod
HEAD :: StdMethod
PUT :: StdMethod
DELETE :: StdMethod
TRACE :: StdMethod
CONNECT :: StdMethod
OPTIONS :: StdMethod
PATCH :: StdMethod

-- | Hook wai middleware into Spock
middleware :: (RouteM t, Monad m) => Middleware -> t ctx m ()
data SpockConfig
SpockConfig :: Maybe Word64 -> (Status -> ActionCtxT () IO ()) -> SpockConfig

-- | Maximum request size in bytes
[sc_maxRequestSize] :: SpockConfig -> Maybe Word64

-- | Error handler. Given status is set in response by default, but you can
--   always override it with <a>setStatus</a>
[sc_errorHandler] :: SpockConfig -> Status -> ActionCtxT () IO ()

-- | Default Spock configuration. No restriction on maximum request size;
--   error handler simply prints status message as plain text.
defaultSpockConfig :: SpockConfig

-- | Specify an action that will be run when a HTTP verb and the given
--   route match
hookRoute' :: (HasRep xs, RouteM t, Monad m) => SpockMethod -> Path xs ps -> HVectElim xs (ActionCtxT ctx m ()) -> t ctx m ()

-- | Specify an action that will be run when a HTTP verb matches but no
--   defined route matches. The full path is passed as an argument
hookAny' :: (RouteM t, Monad m) => SpockMethod -> ([Text] -> ActionCtxT ctx m ()) -> t ctx m ()

-- | The <a>SpockMethod</a> allows safe use of http verbs via the
--   <a>MethodStandard</a> constructor and <a>StdMethod</a>, and custom
--   verbs via the <a>MethodCustom</a> constructor.
data SpockMethod

-- | Standard HTTP Verbs from <a>StdMethod</a>
MethodStandard :: !HttpMethod -> SpockMethod

-- | Custom HTTP Verbs using <a>Text</a>
MethodCustom :: !Text -> SpockMethod
newtype HttpMethod
HttpMethod :: StdMethod -> HttpMethod
[unHttpMethod] :: HttpMethod -> StdMethod
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Web.Spock.Core.SpockCtxT ctx m)
instance GHC.Base.Monad m => GHC.Base.Applicative (Web.Spock.Core.SpockCtxT ctx m)
instance GHC.Base.Functor m => GHC.Base.Functor (Web.Spock.Core.SpockCtxT ctx m)
instance GHC.Base.Monad m => GHC.Base.Monad (Web.Spock.Core.SpockCtxT ctx m)
instance Control.Monad.Trans.Class.MonadTrans (Web.Spock.Core.SpockCtxT ctx)
instance Web.Spock.Routing.RouteM Web.Spock.Core.SpockCtxT
