The basic typeclass for a Yesod application.
- class Eq (Route a) => Yesod a where
- approot :: a -> String
- encryptKey :: a -> IO Key
- clientSessionDuration :: a -> Int
- errorHandler :: ErrorResponse -> GHandler sub a ChooseRep
- defaultLayout :: GWidget sub a () -> GHandler sub a RepHtml
- onRequest :: GHandler sub a ()
- urlRenderOverride :: a -> Route a -> Maybe String
- isAuthorized :: Route a -> Bool -> GHandler s a AuthResult
- isWriteRequest :: Route a -> GHandler s a Bool
- authRoute :: a -> Maybe (Route a)
- splitPath :: a -> ByteString -> Either ByteString [String]
- joinPath :: a -> String -> [String] -> [(String, String)] -> String
- addStaticContent :: String -> String -> ByteString -> GHandler sub a (Maybe (Either String (Route a, [(String, String)])))
- class Eq (Route y) => YesodSite y where
- class Eq (Route s) => YesodSubSite s y where
- class YesodPersist y where
- module Database.Persist
- get404 :: (PersistBackend (t m), PersistEntity val, Monad (t m), Failure ErrorResponse m, MonadTrans t) => Key val -> t m val
- class YesodBreadcrumbs y where
- breadcrumbs :: YesodBreadcrumbs y => GHandler sub y (String, [(Route y, String)])
- maybeAuthorized :: Yesod a => Route a -> Bool -> GHandler s a (Maybe (Route a))
- widgetToPageContent :: (Eq (Route master), Yesod master) => GWidget sub master () -> GHandler sub master (PageContent (Route master))
- defaultLayoutJson :: Yesod master => GWidget sub master () -> Json -> GHandler sub master RepHtmlJson
- defaultErrorHandler :: Yesod y => ErrorResponse -> GHandler sub y ChooseRep
- data AuthResult
Define settings for a Yesod applications. The only required setting is
approot; other than that, there are intelligent defaults.
An absolute URL to the root of the application. Do not include trailing slash.
If you want to be lazy, you can supply an empty string under the following conditions:
- Your application is served from the root of the domain.
- You do not use any features that require absolute URLs, such as Atom feeds and XML sitemaps.
The encryption key to be used for encrypting client sessions.
Number of minutes before a client session times out. Defaults to 120 (2 hours).
Output error response pages.
Applies some form of layout to the contents of a page.
Gets called at the beginning of each request. Useful for logging.
Override the rendering function for a particular URL. One use case for this is to offload static hosting to a different domain name to avoid sending cookies.
Determine if a request is authorized or not.
Determines whether the current request is a write request. By default, this assumes you are following RESTful principles, and determines this from request method. In particular, all except the following request methods are considered write: GET HEAD OPTIONS TRACE.
This function is used to determine if a request is authorized; see
The default route for authentication.
Used in particular by
isAuthorized, but library users can do whatever
they want with it.
By default, it splits paths on slashes, and ensures the following are true:
- No double slashes
- If the last path segment has a period, there is no trailing slash.
- Otherwise, ensures there is a trailing slash.
Join the pieces of a path together into an absolute URL. This should
be the inverse of
|-> GHandler sub a (Maybe (Either String (Route a, [(String, String)])))|
The return value is
Nothing if no storing was performed; this is the
default implementation. A
Left gives the absolute URL of the
file, whereas a
Right gives the type-safe URL. The former is
necessary when you are serving the content outside the context of a
Yesod application, such as via memcached.
This class is automatically instantiated when you use the template haskell mkYesod function. You should never need to deal with it directly.
YesodSite, but for subsites. Once again, users should not need
to deal with it directly, as the mkYesodSub creates instances appropriately.
A type-safe, concise method of creating breadcrumbs for pages. For each resource, you declare the title of the page and the parent resource (if present).
Gets the title of the current page and the hierarchy of parent pages, along with their respective titles.
Return the same URL if the user is authorized to see it.
Built on top of
isAuthorized. This is useful for building page that only
contain links to pages the user is allowed to see.
Convert a widget to a
Provide both an HTML and JSON representation for a piece of data, using
the default layout for the HTML output (
The default error handler for