HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleyesod-core-1.6.26.0Haskell2010

Yesod.Core.Dispatch

  • 4 types
  • 2 classes
  • 28 values

Quasi-quoted routing

7 declarations
valuemkYesod
  1. :: String

    name of the argument datatype

  2. -> [ResourceTree String]
  3. -> 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".

More fine-grained

valuemkYesodData :: String -> [ResourceTree String] -> Q [Dec]
#

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.

Route generation options

datadata RouteOpts
#

General opts data type for generating yesod.

Contains options for what instances are derived for the route. Use the setting functions on defaultOpts to set specific fields.

valuedefaultOpts :: RouteOpts
#

Default options for generating routes.

Defaults to all instances derived.

Helpers

valuedefaultGen :: IO Int
#

Generate a random number uniformly distributed in the full range of Int.

Note: Before 1.6.20, this generates pseudo-random number in an unspecified range. The range size may not be a power of 2. Since 1.6.20, this uses a secure entropy source and generates in the full range of Int.

Path pieces

classclass PathPiece s where
#

Methods

Instances18PathPiece, …

Convert to WAI

8 declarations
valuetoWaiApp :: YesodDispatch site => site -> IO Application
#

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

valuetoWaiAppPlain :: YesodDispatch site => site -> IO Application
#

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.

valuewarp :: YesodDispatch site => Int -> site -> IO ()
#

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:

  • 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

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

Since 1.2.0

valuewarpEnv :: YesodDispatch site => site -> IO ()
#

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.

WAI subsites

2 declarations
newtypenewtype WaiSubsite
#

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

Instances8ParseRoute, RenderRoute, YesodSubDispatch, Eq, Ord, Read, …
newtypenewtype WaiSubsiteWithAuth
#

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

Instances8ParseRoute, RenderRoute, YesodSubDispatch, Eq, Ord, Read, …