yesod-core-1.6.17.3: Creation of type-safe, RESTful web applications.

Safe HaskellNone
LanguageHaskell98

Yesod.Core.Dispatch

Contents

Synopsis

Quasi-quoted routing

parseRoutes :: QuasiQuoter Source #

A quasi-quoter to parse a string into a list of Resources. Checks for overlapping routes, failing if present; use parseRoutesNoCheck to skip the checking. See documentation site for details on syntax.

parseRoutesNoCheck :: QuasiQuoter Source #

Same as parseRoutes, but performs no overlap checking.

mkYesod Source #

Arguments

:: String

name of the argument datatype

-> [ResourceTree String] 
-> Q [Dec] 

Generates URL datatype and site function for the given Resources. This is used for creating sites, not subsites. See mkYesodSubData and mkYesodSubDispatch for the latter. Use parseRoutes to create the Resources.

Contexts and type variables in the name of the datatype are parsed. For example, a datatype App a with typeclass constraint MyClass a can be written as "(MyClass a) => App a".

mkYesodWith Source #

Arguments

:: [[String]]

list of contexts

-> String

name of the argument datatype

-> [String]

list of type variables

-> [ResourceTree String] 
-> Q [Dec] 

Deprecated: Contexts and type variables are now parsed from the name in mkYesod. https://github.com/yesodweb/yesod/pull/1366

Similar to mkYesod, except contexts and type variables are not parsed. Instead, they are explicitly provided. You can write (MyClass a) => App a with mkYesodWith [["MyClass","a"]] "App" ["a"] ....

More fine-grained

mkYesodData :: String -> [ResourceTree String] -> Q [Dec] Source #

Sometimes, you will want to declare your routes in one file and define your handlers elsewhere. For example, this is the only way to break up a monolithic file into smaller parts. Use this function, paired with mkYesodDispatch, to do just that.

Helpers

getGetMaxExpires :: IO (IO Text) Source #

Default constructor for yreGetMaxExpires field. Low level function for simple manual construction of YesodRunnerEnv.

Since: 1.4.29

Path pieces

class PathPiece s where #

Methods

fromPathPiece :: Text -> Maybe s #

toPathPiece :: s -> Text #

Instances
PathPiece Bool 
Instance details

Defined in Web.PathPieces

PathPiece Int 
Instance details

Defined in Web.PathPieces

PathPiece Int8 
Instance details

Defined in Web.PathPieces

PathPiece Int16 
Instance details

Defined in Web.PathPieces

PathPiece Int32 
Instance details

Defined in Web.PathPieces

PathPiece Int64 
Instance details

Defined in Web.PathPieces

PathPiece Integer 
Instance details

Defined in Web.PathPieces

PathPiece Word 
Instance details

Defined in Web.PathPieces

PathPiece Word8 
Instance details

Defined in Web.PathPieces

PathPiece Word16 
Instance details

Defined in Web.PathPieces

PathPiece Word32 
Instance details

Defined in Web.PathPieces

PathPiece Word64 
Instance details

Defined in Web.PathPieces

PathPiece () 
Instance details

Defined in Web.PathPieces

Methods

fromPathPiece :: Text -> Maybe () #

toPathPiece :: () -> Text #

PathPiece Text 
Instance details

Defined in Web.PathPieces

PathPiece String 
Instance details

Defined in Web.PathPieces

PathPiece Text 
Instance details

Defined in Web.PathPieces

PathPiece Day 
Instance details

Defined in Web.PathPieces

PathPiece a => PathPiece (Maybe a) 
Instance details

Defined in Web.PathPieces

class PathMultiPiece s where #

Instances
PathPiece a => PathMultiPiece [a] 
Instance details

Defined in Web.PathPieces

Methods

fromPathMultiPiece :: [Text] -> Maybe [a] #

toPathMultiPiece :: [a] -> [Text] #

type Texts = [Text] Source #

Convert to WAI

toWaiApp :: YesodDispatch site => site -> IO Application Source #

Same as toWaiAppPlain, but provides a default set of middlewares. This set may change with future releases, but currently covers:

  • Logging
  • GZIP compression
  • Automatic HEAD method handling
  • Request method override with the _method query string parameter
  • Accept header override with the _accept query string parameter

toWaiAppPlain :: YesodDispatch site => site -> IO Application Source #

Convert the given argument into a WAI application, executable with any WAI handler. This function will provide no middlewares; if you want commonly used middlewares, please use toWaiApp.

toWaiAppYre :: YesodDispatch site => YesodRunnerEnv site -> Application Source #

Pure low level function to construct WAI application. Usefull when you need not standard way to run your app, or want to embed it inside another app.

Since: 1.4.29

warp :: YesodDispatch site => Int -> site -> IO () Source #

A convenience method to run an application using the Warp webserver on the specified port. Automatically calls toWaiApp. Provides a default set of middlewares. This set may change at any point without a breaking version number. Currently, it includes:

If you need more fine-grained control of middlewares, please use toWaiApp directly.

Since 1.2.0

warpDebug :: YesodDispatch site => Int -> site -> IO () Source #

Deprecated: Please use warp instead

Deprecated synonym for warp.

warpEnv :: YesodDispatch site => site -> IO () Source #

Runs your application using default middlewares (i.e., via toWaiApp). It reads port information from the PORT environment variable, as used by tools such as Keter and the FP Complete School of Haskell.

Note that the exact behavior of this function may be modified slightly over time to work correctly with external tools, without a change to the type signature.

mkDefaultMiddlewares :: Logger -> IO Middleware Source #

A default set of middlewares.

Since 1.2.0

defaultMiddlewaresNoLogging :: Middleware Source #

All of the default middlewares, excluding logging.

Since 1.2.12

WAI subsites

newtype WaiSubsite Source #

Wrap up a normal WAI application as a Yesod subsite. Ignore parent site's middleware and isAuthorized.

Constructors

WaiSubsite 
Instances
ParseRoute WaiSubsite Source # 
Instance details

Defined in Yesod.Core.Types

Methods

parseRoute :: ([Text], [(Text, Text)]) -> Maybe (Route WaiSubsite) Source #

RenderRoute WaiSubsite Source # 
Instance details

Defined in Yesod.Core.Types

Associated Types

data Route WaiSubsite :: Type Source #

Methods

renderRoute :: Route WaiSubsite -> ([Text], [(Text, Text)]) Source #

YesodSubDispatch WaiSubsite master Source # 
Instance details

Defined in Yesod.Core.Class.Dispatch

Eq (Route WaiSubsite) Source # 
Instance details

Defined in Yesod.Core.Types

Ord (Route WaiSubsite) Source # 
Instance details

Defined in Yesod.Core.Types

Read (Route WaiSubsite) Source # 
Instance details

Defined in Yesod.Core.Types

Show (Route WaiSubsite) Source # 
Instance details

Defined in Yesod.Core.Types

data Route WaiSubsite Source # 
Instance details

Defined in Yesod.Core.Types

newtype WaiSubsiteWithAuth Source #

Like WaiSubsite, but applies parent site's middleware and isAuthorized.

Since: 1.4.34

Instances
ParseRoute WaiSubsiteWithAuth Source # 
Instance details

Defined in Yesod.Core.Types

RenderRoute WaiSubsiteWithAuth Source # 
Instance details

Defined in Yesod.Core.Types

Associated Types

data Route WaiSubsiteWithAuth :: Type Source #

YesodSubDispatch WaiSubsiteWithAuth master Source # 
Instance details

Defined in Yesod.Core.Class.Dispatch

Eq (Route WaiSubsiteWithAuth) Source # 
Instance details

Defined in Yesod.Core.Types

Ord (Route WaiSubsiteWithAuth) Source # 
Instance details

Defined in Yesod.Core.Types

Read (Route WaiSubsiteWithAuth) Source # 
Instance details

Defined in Yesod.Core.Types

Show (Route WaiSubsiteWithAuth) Source # 
Instance details

Defined in Yesod.Core.Types

data Route WaiSubsiteWithAuth Source # 
Instance details

Defined in Yesod.Core.Types