-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Another Haskell web framework for rapid development -- -- This toolbox provides everything you need to get a quick start into -- web hacking with haskell: -- -- -- -- A tutorial is available at spock.li @package Spock @version 0.10.0.1 module Web.Spock.Internal.SessionVault class (Eq (SessionKey s), Hashable (SessionKey s)) => IsSession s where type family SessionKey s :: * getSessionKey :: IsSession s => s -> SessionKey s newtype SessionVault s SessionVault :: Map (SessionKey s) s -> SessionVault s [unSessionVault] :: SessionVault s -> Map (SessionKey s) s -- | Create a new session vault newSessionVault :: IsSession s => STM (SessionVault s) -- | Load a session loadSession :: IsSession s => SessionKey s -> SessionVault s -> STM (Maybe s) -- | Store a session, overwriting any previous values storeSession :: IsSession s => s -> SessionVault s -> STM () -- | Removea session deleteSession :: IsSession s => SessionKey s -> SessionVault s -> STM () -- | Get all sessions as list toList :: IsSession s => SessionVault s -> STM [s] -- | Remove all sessions that do not match the predicate filterSessions :: IsSession s => (s -> Bool) -> SessionVault s -> STM () -- | Perform action on all sessions mapSessions :: IsSession s => (s -> STM s) -> SessionVault s -> STM () instance Web.Spock.Internal.SessionVault.IsSession (Web.Spock.Internal.Types.Session conn sess st) 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.Internal.Cookies -- | Cookie settings data CookieSettings CookieSettings :: CookieEOL -> Maybe ByteString -> Maybe ByteString -> Bool -> Bool -> CookieSettings -- | cookie expiration setting, see CookieEOL [cs_EOL] :: CookieSettings -> CookieEOL -- | a path for the cookie [cs_path] :: CookieSettings -> Maybe ByteString -- | a domain for the cookie. Nothing 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 -- --
--   CookieSettings
--     { cs_EOL      = CookieValidForSession
--     , cs_HTTPOnly = False
--     , cs_secure   = False
--     , cs_domain   = Nothing
--     , cs_path     = Just "/"
--     }
--   
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 generateCookieHeaderString :: Text -> Text -> CookieSettings -> UTCTime -> ByteString parseCookies :: ByteString -> [(Text, Text)] module Web.Spock.Shared -- | Run a Spock application. Basically just a wrapper aroung run. runSpock :: Port -> IO Middleware -> IO () -- | Like runSpock, 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 -- | The SpockAction is a specialisation of SpockActionCtx -- with a '()' context. type SpockAction conn sess st = SpockActionCtx () conn sess st -- | The SpockActionCtx is the monad of all route-actions. You have -- access to the context of the request and database, session and state -- of your application. type SpockActionCtx ctx conn sess st = ActionCtxT ctx (WebStateM conn sess st) 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 a cookie. The cookie value will already be urldecoded. cookie :: MonadIO m => Text -> ActionCtxT ctx m (Maybe Text) -- | Returns the current request method, e.g. GET reqMethod :: MonadIO m => ActionCtxT ctx m StdMethod -- | 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 params params :: MonadIO m => ActionCtxT ctx m [(Text, Text)] -- | Read a request param. Spock looks in route captures first (in simple -- routing), then in POST variables and at last in GET variables param :: (PathPiece p, MonadIO m) => Text -> ActionCtxT ctx m (Maybe p) -- | Like param, but outputs an error when a param is missing param' :: (PathPiece 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 setMultiHeader. 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 CookieEOL [cs_EOL] :: CookieSettings -> CookieEOL -- | a path for the cookie [cs_path] :: CookieSettings -> Maybe ByteString -- | a domain for the cookie. Nothing 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 -- --
--   CookieSettings
--     { cs_EOL      = CookieValidForSession
--     , cs_HTTPOnly = False
--     , cs_secure   = False
--     , cs_domain   = Nothing
--     , cs_path     = Just "/"
--     }
--   
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 -- | 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 ByteString as response body. Provide your own -- Content-Type bytes :: MonadIO m => ByteString -> ActionCtxT ctx m a -- | Send a lazy ByteString as response body. Provide your own -- Content-Type lazyBytes :: MonadIO m => ByteString -> ActionCtxT ctx m a -- | 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 StreamingBody to generate a response. stream :: MonadIO m => StreamingBody -> ActionCtxT ctx m a -- | Use a custom Response generator as response body. response :: MonadIO m => (Status -> ResponseHeaders -> Response) -> 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) -- | Spock configuration, use defaultSpockCfg and change single -- values if needed data SpockCfg conn sess st SpockCfg :: st -> PoolOrConn conn -> SessionCfg sess -> Maybe Word64 -> SpockCfg conn sess st -- | initial application global state [spc_initialState] :: SpockCfg conn sess st -> st -- | See PoolOrConn [spc_database] :: SpockCfg conn sess st -> PoolOrConn conn -- | See SessionCfg [spc_sessionCfg] :: SpockCfg conn sess st -> SessionCfg sess -- | Maximum request size in bytes. Nothing means no limit. Defaults -- to 5 MB in defaultSpockCfg. [spc_maxRequestSize] :: SpockCfg conn sess st -> Maybe Word64 -- | Spock configuration with reasonable defaults defaultSpockCfg :: sess -> PoolOrConn conn -> st -> SpockCfg conn sess st -- | You can feed Spock with either a connection pool, or instructions on -- how to build a connection pool. See ConnBuilder data PoolOrConn a PCPool :: Pool a -> PoolOrConn a PCConn :: ConnBuilder a -> PoolOrConn a PCNoDatabase :: PoolOrConn () -- | The ConnBuilder instructs Spock how to create or close a database -- connection. data ConnBuilder a ConnBuilder :: IO a -> (a -> IO ()) -> PoolCfg -> ConnBuilder a [cb_createConn] :: ConnBuilder a -> IO a [cb_destroyConn] :: ConnBuilder a -> a -> IO () [cb_poolConfiguration] :: ConnBuilder a -> PoolCfg -- | If Spock should take care of connection pooling, you need to configure -- it depending on what you need. data PoolCfg PoolCfg :: Int -> Int -> NominalDiffTime -> PoolCfg [pc_stripes] :: PoolCfg -> Int [pc_resPerStripe] :: PoolCfg -> Int [pc_keepOpenTime] :: PoolCfg -> NominalDiffTime class HasSpock m where type family SpockConn m :: * type family SpockState m :: * type family SpockSession m :: * -- | Give you access to a database connectin from the connection pool. The -- connection is released back to the pool once the function terminates. runQuery :: HasSpock m => (SpockConn m -> IO a) -> m a -- | Read the application's state. If you wish to have mutable state, you -- could use a TVar from the STM packge. getState :: HasSpock m => m (SpockState m) -- | Convenience Basic authentification provide a title for the prompt and -- a function to validate user and password. Usage example: -- --
--   get ("auth" <//> var <//> var) $ \user pass ->
--         let checker user' pass' =
--                 unless (user == user' && pass == pass') $
--                 do setStatus status401
--                    text "err"
--         in requireBasicAuth "Foo" checker $ \() -> text "ok"
--   
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 -- Authorization 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 -- | Session configuration with reasonable defaults defaultSessionCfg :: a -> SessionCfg a -- | Configuration for the session manager data SessionCfg a SessionCfg :: Text -> NominalDiffTime -> Int -> Bool -> a -> Maybe (SessionPersistCfg a) -> NominalDiffTime -> SessionHooks a -> SessionCfg a -- | name of the client side cookie [sc_cookieName] :: SessionCfg a -> Text -- | how long shoud a client session live [sc_sessionTTL] :: SessionCfg a -> NominalDiffTime -- | entropy of the session id sent to the client [sc_sessionIdEntropy] :: SessionCfg a -> Int -- | if this is true, every page reload will renew the session time to live -- counter [sc_sessionExpandTTL] :: SessionCfg a -> Bool -- | initial session for visitors [sc_emptySession] :: SessionCfg a -> a -- | persistence interface for sessions [sc_persistCfg] :: SessionCfg a -> Maybe (SessionPersistCfg a) -- | how often should the session manager check for dangeling dead sessions [sc_housekeepingInterval] :: SessionCfg a -> NominalDiffTime -- | hooks into the session manager [sc_hooks] :: SessionCfg a -> SessionHooks a -- | NOP session hooks defaultSessionHooks :: SessionHooks a -- | Hook into the session manager to trigger custom behavior data SessionHooks a SessionHooks :: (HashMap SessionId a -> IO ()) -> SessionHooks a [sh_removed] :: SessionHooks a -> HashMap SessionId a -> IO () data SessionPersistCfg a SessionPersistCfg :: IO [(SessionId, UTCTime, a)] -> ([(SessionId, UTCTime, a)] -> IO ()) -> SessionPersistCfg a [spc_load] :: SessionPersistCfg a -> IO [(SessionId, UTCTime, a)] [spc_store] :: SessionPersistCfg a -> [(SessionId, UTCTime, a)] -> IO () -- | Simple session persisting configuration. DO NOT USE IN PRODUCTION readShowSessionPersist :: (Read a, Show a) => FilePath -> SessionPersistCfg a type SessionId = Text -- | Regenerate the users sessionId. This preserves all stored data. Call -- this prior to logging in a user to prevent session fixation attacks. sessionRegenerateId :: SpockActionCtx ctx conn sess st () -- | Get the current users sessionId. Note that this ID should only be -- shown to it's owner as otherwise sessions can be hijacked. getSessionId :: SpockActionCtx ctx conn sess st SessionId -- | Read the stored session readSession :: SpockActionCtx ctx conn sess st sess -- | Write to the current session. Note that all data is stored on the -- server. The user only reciedes a sessionId to be identified. writeSession :: sess -> SpockActionCtx ctx conn sess st () -- | Modify the stored session modifySession :: (sess -> sess) -> SpockActionCtx ctx conn sess st () -- | Modify the stored session and return a value modifySession' :: (sess -> (sess, a)) -> SpockActionCtx ctx conn sess st a -- | Modify the stored session and return the new value after modification modifyReadSession :: (sess -> sess) -> SpockActionCtx ctx conn sess st sess -- | Apply a transformation to all sessions. Be careful with this, as this -- may cause many STM transaction retries. mapAllSessions :: (sess -> STM sess) -> SpockActionCtx ctx conn sess st () -- | Globally delete all existing sessions. This is useful for example if -- you want to require all users to relogin clearAllSessions :: SpockActionCtx ctx conn sess st () -- | Read the heart of Spock. This is useful if you want to construct your -- own monads that work with runQuery and getState using "runSpockIO" getSpockHeart :: MonadTrans t => t (WebStateM conn sess st) (WebState conn sess st) -- | Run an action inside of Spocks core monad. This allows you to use -- runQuery and getState runSpockIO :: WebState conn sess st -> WebStateM conn sess st a -> IO a type WebStateM conn sess st = WebStateT conn sess st (ResourceT IO) data WebState conn sess st -- | Since version 0.7 Spock features a new routing system that enables -- more type-safe code while still being relatively simple and -- lightweight. You should consider using that (see -- Web.Spock.Safe) instead of this module. This module is not yet -- deprecated, but this may happen anytime soon. module Web.Spock.Simple -- | Create a spock application using a given db storageLayer and an -- initial state. Spock works with database libraries that already -- implement connection pooling and with those that don't come with it -- out of the box. For more see the PoolOrConn type. Use -- runSpock to run the app or spockAsApp to create a -- Wai.Application spock :: SpockCfg conn sess st -> SpockM conn sess st () -> IO Middleware type SpockM conn sess st a = SpockT (WebStateM conn sess st) a -- | Create a raw spock application with custom underlying monad Use -- runSpock to run the app or spockAsApp to create a -- Wai.Application. spockT :: (MonadIO m) => (forall a. m a -> IO a) -> SpockT m () -> IO Middleware -- | Like spockT, but the first argument is request size limit in -- bytes. Set to Nothing to disable. spockLimT :: (MonadIO m) => Maybe Word64 -> (forall a. m a -> IO a) -> SpockT m () -> IO Middleware data SpockT m a data SpockRoute -- | Combine two route components safely -- --
--   >>> "/foo" <//> "/bar"
--   "/foo/bar"
--   
-- --
--   >>> "foo" <//> "bar"
--   "/foo/bar"
--   
-- --
--   >>> "foo <//> "/bar"
--   "/foo/bar"
--   
() :: SpockRoute -> SpockRoute -> SpockRoute -- | Define a subcomponent. Usage example: -- --
--   subcomponent "site" $
--     do get "home" homeHandler
--        get ("misc" <//> ":param") $ -- ...
--   subcomponent "/admin" $
--     get "home" adminHomeHandler
--   
-- -- The request /site/home will be routed to homeHandler and the request -- /admin/home will be routed to adminHomeHandler subcomponent :: Monad m => SpockRoute -> SpockT m () -> SpockT m () -- | Specify an action that will be run when the HTTP verb GET and -- the given route match get :: MonadIO m => SpockRoute -> ActionT m () -> SpockT m () -- | Specify an action that will be run when the HTTP verb POST and -- the given route match post :: MonadIO m => SpockRoute -> ActionT m () -> SpockT m () -- | Specify an action that will be run when the HTTP verb 'GET'/'POST' and -- the given route match getpost :: MonadIO m => SpockRoute -> ActionT m () -> SpockT m () -- | Specify an action that will be run when the HTTP verb HEAD and -- the given route match head :: MonadIO m => SpockRoute -> ActionT m () -> SpockT m () -- | Specify an action that will be run when the HTTP verb PUT and -- the given route match put :: MonadIO m => SpockRoute -> ActionT m () -> SpockT m () -- | Specify an action that will be run when the HTTP verb DELETE -- and the given route match delete :: MonadIO m => SpockRoute -> ActionT m () -> SpockT m () -- | Specify an action that will be run when the HTTP verb PATCH and -- the given route match patch :: MonadIO m => SpockRoute -> ActionT m () -> SpockT m () -- | Specify an action that will be run when a HTTP verb and the given -- route match hookRoute :: Monad m => StdMethod -> SpockRoute -> ActionT m () -> SpockT 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 :: Monad m => StdMethod -> ([Text] -> ActionT m ()) -> SpockT 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 :: Monad m => Middleware -> SpockT m () -- | SafeActions are actions that need to be protected from csrf attacks class (Hashable a, Eq a, Typeable a) => SafeAction conn sess st a -- | The body of the safe action. Either GET or POST runSafeAction :: SafeAction conn sess st a => a -> SpockAction conn sess st () -- | Wire up a safe action: Safe actions are actions that are protected -- from csrf attacks. Here's a usage example: -- --
--   newtype DeleteUser = DeleteUser Int deriving (Hashable, Typeable, Eq)
--   
--   instance SafeAction Connection () () DeleteUser where
--      runSafeAction (DeleteUser i) =
--         do runQuery $ deleteUserFromDb i
--            redirect "/user-list"
--   
--   get ("user-details" <//> ":userId") $
--     do userId <- param' "userId"
--        deleteUrl <- safeActionPath (DeleteUser userId)
--        html $ "Click <a href='" <> deleteUrl <> "'>here</a> to delete user!"
--   
-- -- Note that safeActions currently only support GET and POST requests. safeActionPath :: (SafeAction conn sess st a, HasSpock (SpockAction conn sess st), SpockConn (SpockAction conn sess st) ~ conn, SpockSession (SpockAction conn sess st) ~ sess, SpockState (SpockAction conn sess st) ~ st) => a -> SpockAction conn sess st Text instance GHC.Read.Read Web.Spock.Simple.SpockRoute instance GHC.Show.Show Web.Spock.Simple.SpockRoute instance GHC.Classes.Ord Web.Spock.Simple.SpockRoute instance GHC.Classes.Eq Web.Spock.Simple.SpockRoute instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Web.Spock.Simple.SpockT m) instance GHC.Base.Monad m => GHC.Base.Applicative (Web.Spock.Simple.SpockT m) instance GHC.Base.Functor m => GHC.Base.Functor (Web.Spock.Simple.SpockT m) instance GHC.Base.Monad m => GHC.Base.Monad (Web.Spock.Simple.SpockT m) instance Control.Monad.Trans.Class.MonadTrans Web.Spock.Simple.SpockT instance Data.String.IsString Web.Spock.Simple.SpockRoute -- | This module implements the type safe routing aproach. It should be -- used by all new Spock powered applications. To learn more about the -- routing, read the corresponding blog post available at -- http://www.spock.li/2015/04/19/type-safe_routing.html module Web.Spock.Safe -- | Create a spock application using a given db storageLayer and an -- initial state. Spock works with database libraries that already -- implement connection pooling and with those that don't come with it -- out of the box. For more see the PoolOrConn type. Use -- runSpock to run the app or spockAsApp to create a -- Wai.Application spock :: SpockCfg conn sess st -> SpockM conn sess st () -> IO Middleware type SpockM conn sess st = SpockCtxM () conn sess st type SpockCtxM ctx conn sess st = SpockCtxT ctx (WebStateM conn sess st) -- | Create a raw spock application with custom underlying monad Use -- runSpock to run the app or spockAsApp to create a -- Wai.Application The first argument is request size limit in -- bytes. Set to Nothing to disable. spockT :: (MonadIO m) => (forall a. m a -> IO a) -> SpockT m () -> IO Middleware -- | Like spockT, but first argument is request size limit in -- bytes. Set to Nothing to disable. spockLimT :: MonadIO m => Maybe Word64 -> (forall a. m a -> IO a) -> SpockT m () -> IO Middleware type SpockT = SpockCtxT () data SpockCtxT ctx m a data Path (as :: [*]) :: [*] -> * -- | The root of a path piece. Use to define a handler for "/" root :: Path ([] *) type Var a = Path ((:) * a ([] *)) -- | A route parameter var :: (Typeable * a, PathPiece a) => Path ((:) * a ([] *)) -- | A static route piece static :: String -> Path ([] *) -- | Combine two path components () :: Path as -> Path bs -> Path (Append as bs) -- | Render a route applying path pieces renderRoute :: Path as -> HVectElim as Text -- | Define a subcomponent. Usage example: -- --
--   subcomponent "site" $
--     do get "home" homeHandler
--        get ("misc" <//> var) $ -- ...
--   subcomponent "admin" $
--     do get "home" adminHomeHandler
--   
-- -- The request /site/home will be routed to homeHandler and the request -- /admin/home will be routed to adminHomeHandler subcomponent :: Monad m => Path '[] -> SpockCtxT ctx m () -> SpockCtxT ctx m () -- | Specify an action that will be run before all subroutes. It can modify -- the requests current context prehook :: MonadIO m => ActionCtxT ctx m ctx' -> SpockCtxT ctx' m () -> SpockCtxT ctx m () -- | Specify an action that will be run when the HTTP verb GET and -- the given route match get :: (HasRep xs, MonadIO m) => Path xs -> HVectElim xs (ActionCtxT ctx m ()) -> SpockCtxT ctx m () -- | Specify an action that will be run when the HTTP verb POST and -- the given route match post :: (HasRep xs, MonadIO m) => Path xs -> HVectElim xs (ActionCtxT ctx m ()) -> SpockCtxT ctx m () -- | Specify an action that will be run when the HTTP verb 'GET'/'POST' and -- the given route match getpost :: (HasRep xs, MonadIO m) => Path xs -> HVectElim xs (ActionCtxT ctx m ()) -> SpockCtxT ctx m () -- | Specify an action that will be run when the HTTP verb HEAD and -- the given route match head :: (HasRep xs, MonadIO m) => Path xs -> HVectElim xs (ActionCtxT ctx m ()) -> SpockCtxT ctx m () -- | Specify an action that will be run when the HTTP verb PUT and -- the given route match put :: (HasRep xs, MonadIO m) => Path xs -> HVectElim xs (ActionCtxT ctx m ()) -> SpockCtxT ctx m () -- | Specify an action that will be run when the HTTP verb DELETE -- and the given route match delete :: (HasRep xs, MonadIO m) => Path xs -> HVectElim xs (ActionCtxT ctx m ()) -> SpockCtxT ctx m () -- | Specify an action that will be run when the HTTP verb PATCH and -- the given route match patch :: (HasRep xs, MonadIO m) => Path xs -> HVectElim xs (ActionCtxT ctx m ()) -> SpockCtxT ctx m () -- | Specify an action that will be run when a HTTP verb and the given -- route match hookRoute :: (HasRep xs, Monad m) => StdMethod -> Path xs -> HVectElim xs (ActionCtxT ctx m ()) -> SpockCtxT 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 :: Monad m => StdMethod -> ([Text] -> ActionCtxT ctx m ()) -> SpockCtxT 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 :: Monad m => Middleware -> SpockCtxT ctx m () -- | SafeActions are actions that need to be protected from csrf attacks class (Hashable a, Eq a, Typeable a) => SafeAction conn sess st a -- | The body of the safe action. Either GET or POST runSafeAction :: SafeAction conn sess st a => a -> SpockAction conn sess st () -- | Wire up a safe action: Safe actions are actions that are protected -- from csrf attacks. Here's a usage example: -- --
--   newtype DeleteUser = DeleteUser Int deriving (Hashable, Typeable, Eq)
--   
--   instance SafeAction Connection () () DeleteUser where
--      runSafeAction (DeleteUser i) =
--         do runQuery $ deleteUserFromDb i
--            redirect "/user-list"
--   
--   get ("user-details" <//> var) $ \userId ->
--     do deleteUrl <- safeActionPath (DeleteUser userId)
--        html $ "Click <a href='" <> deleteUrl <> "'>here</a> to delete user!"
--   
-- -- Note that safeActions currently only support GET and POST requests. safeActionPath :: (SafeAction conn sess st a, HasSpock (SpockAction conn sess st), SpockConn (SpockAction conn sess st) ~ conn, SpockSession (SpockAction conn sess st) ~ sess, SpockState (SpockAction conn sess st) ~ st) => a -> SpockAction conn sess st Text instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Web.Spock.Safe.SpockCtxT ctx m) instance GHC.Base.Monad m => GHC.Base.Applicative (Web.Spock.Safe.SpockCtxT ctx m) instance GHC.Base.Functor m => GHC.Base.Functor (Web.Spock.Safe.SpockCtxT ctx m) instance GHC.Base.Monad m => GHC.Base.Monad (Web.Spock.Safe.SpockCtxT ctx m) instance Control.Monad.Trans.Class.MonadTrans (Web.Spock.Safe.SpockCtxT ctx) -- | This module reexports type safe routing aproach which should be the -- default for all Spock applications. To learn more about the routing, -- read the corresponding blog post available at -- http://www.spock.li/2015/04/19/type-safe_routing.html module Web.Spock