| 1 |
-- | This module is essentially identical to 'Web.Scotty.Trans', except that |
| 2 |
-- some functions take/return strict Text instead of the lazy ones. |
| 3 |
-- |
| 4 |
-- It should be noted that most of the code snippets below depend on the |
| 5 |
-- OverloadedStrings language pragma. |
| 6 |
-- |
| 7 |
-- The functions in this module allow an arbitrary monad to be embedded |
| 8 |
-- in Scotty's monad transformer stack in order that Scotty be combined |
| 9 |
-- with other DSLs. |
| 10 |
-- |
| 11 |
-- Scotty is set up by default for development mode. For production servers, |
| 12 |
-- you will likely want to modify 'settings' and the 'defaultHandler'. See |
| 13 |
-- the comments on each of these functions for more information. |
| 14 |
module Web.Scotty.Trans.Strict |
| 15 |
( -- * scotty-to-WAI |
| 16 |
scottyT, scottyAppT, scottyOptsT, scottySocketT, Options(..), defaultOptions |
| 17 |
-- * Defining Middleware and Routes |
| 18 |
-- |
| 19 |
-- | 'Middleware' and routes are run in the order in which they |
| 20 |
-- are defined. All middleware is run first, followed by the first |
| 21 |
-- route that matches. If no route matches, a 404 response is given. |
| 22 |
, middleware, get, post, put, delete, patch, options, addroute, matchAny, notFound, setMaxRequestBodySize |
| 23 |
-- ** Route Patterns |
| 24 |
, capture, regex, function, literal |
| 25 |
-- ** Accessing the Request, Captures, and Query Parameters |
| 26 |
, request, Base.header, Base.headers, body, bodyReader |
| 27 |
, param, params |
| 28 |
, captureParam, formParam, queryParam |
| 29 |
, captureParamMaybe, formParamMaybe, queryParamMaybe |
| 30 |
, captureParams, formParams, queryParams |
| 31 |
, jsonData, files |
| 32 |
-- ** Modifying the Response and Redirecting |
| 33 |
, status, Base.addHeader, Base.setHeader, Base.redirect |
| 34 |
-- ** Setting Response Body |
| 35 |
-- |
| 36 |
-- | Note: only one of these should be present in any given route |
| 37 |
-- definition, as they completely replace the current 'Response' body. |
| 38 |
, Base.text, Base.html, file, json, stream, raw, nested |
| 39 |
, textLazy |
| 40 |
, htmlLazy |
| 41 |
-- ** Accessing the fields of the Response |
| 42 |
, getResponseHeaders, getResponseStatus, getResponseContent |
| 43 |
-- ** Exceptions |
| 44 |
, Base.raise, Base.raiseStatus, throw, rescue, next, finish, defaultHandler, liftAndCatchIO |
| 45 |
, StatusError(..) |
| 46 |
, ScottyException(..) |
| 47 |
-- * Parsing Parameters |
| 48 |
, Param, Parsable(..), readEither |
| 49 |
-- * Types |
| 50 |
, RoutePattern, File, Content(..), Kilobytes, ErrorHandler, Handler(..) |
| 51 |
-- * Monad Transformers |
| 52 |
, ScottyT, ActionT |
| 53 |
, ScottyState, defaultScottyState |
| 54 |
) where |
| 55 |
import Web.Scotty.Action as Base |
| 56 |
import Web.Scotty.Trans |