Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type RestT m = ActionT RestException m
- rest :: MonadIO m => RoutePattern -> Config m -> ScottyT RestException m ()
- data Authorized
- data DeleteResult
- data ETag
- data Moved
- = NotMoved
- | MovedTemporarily !Url
- | MovedPermanently !Url
- data ProcessingResult
- = Succeeded
- | SucceededWithContent !MediaType !Text
- | SucceededWithLocation !Url
- | Redirect !Url
- | Failed
- data Representation
- data EndpointConfig m = EndpointConfig {
- allowedMethods :: m [StdMethod]
- resourceExists :: m Bool
- previouslyExisted :: m Bool
- isConflict :: m Bool
- contentTypesAccepted :: m [(MediaType, m ProcessingResult)]
- contentTypesProvided :: m [(MediaType, m ())]
- languagesProvided :: m (Maybe [Language])
- charsetsProvided :: m (Maybe [Text])
- deleteResource :: m DeleteResult
- optionsHandler :: m (Maybe (MediaType, m ()))
- generateEtag :: m (Maybe ETag)
- expires :: m (Maybe UTCTime)
- lastModified :: m (Maybe UTCTime)
- malformedRequest :: m Bool
- isAuthorized :: m Authorized
- forbidden :: m Bool
- serviceAvailable :: m Bool
- allowMissingPost :: m Bool
- multipleChoices :: m Representation
- resourceMoved :: m Moved
- variances :: m [Text]
- defaultConfig :: Monad m => Config m
- data RestException
- data MediaType :: *
- data StdMethod :: *
- data UTCTime :: *
- toHttpDateHeader :: UTCTime -> Text
- requestMethod :: Monad m => RestT m StdMethod
REST monad transformer
type RestT m = ActionT RestException m Source #
REST handler to Scotty
rest :: MonadIO m => RoutePattern -> Config m -> ScottyT RestException m () Source #
rest is used where you would use e.g. get
in your Scotty app, and
will match any method:
main = scotty 3000 $ do get "/foo" (text "Hello!") rest "/bar" defaultConfig { contentTypesProvided = return [("text/html", html "Hello, World!")] }
Callback result types
data Authorized Source #
Response to isAuthorized
callback.
Authorized | User is authenticated and authorized. |
NotAuthorized !Text | User is not authorized. The given challenge will be sent as part of the WWW-Authenticate header. |
data DeleteResult Source #
Response to deleteResource
callback.
NotDeleted | The resource could not be deleted. |
Deleted | The deletion operation has been fully completed. |
DeletedWithResponse !MediaType !Text | The deletion operation has been fully completed. Respond with the given body. |
DeleteEnacted | Accepted for processing, but the processing has not been completed (and may never be). |
An ETag validator generated by the generateEtag
callback.
Result of the resourceMoved
callback.
NotMoved | Resource has not moved. |
MovedTemporarily !Url | Resource has been temporarily moved to the given URL. |
MovedPermanently !Url | Resource has been permanently moved to the given URL. |
data ProcessingResult Source #
Succeeded | Processing succeeded. Returns 204 No Content or 201 Created based on whether the resource existed previously or not. |
SucceededWithContent !MediaType !Text | Processing succeeded with the given content. Returns 201 Created or 200 OK/300 Multiple Representations based on whether the resource existed previously or not. |
SucceededWithLocation !Url | Processing succeeded with the given content. Returns 201 Created or 200 OK/300 Multiple Representations based on whether the resource existed previously or not. |
Redirect !Url | Redirects (with 303 See Other) to the given URL. |
Failed | Processing failed. Returns 400 Bad Request. |
data Representation Source #
Response to multipleChoices
callback.
UniqueRepresentation | The resource has a unique representation. |
MultipleRepresentations !MediaType !Text | There are multiple representations of this resource. Respond with the given body. |
MultipleWithPreferred !MediaType !Text !Url | There are multiple representations of this resource, but one is preferred.
Respond with the given body, and |
Config
data EndpointConfig m Source #
The callbacks that control a handler's behaviour. defaultConfig
returns a config
with default values. For typical handlers, you only need to override a few of these callbacks.
EndpointConfig | |
|
defaultConfig :: Monad m => Config m Source #
A RestConfig
with default values. To override one or more fields, use
record syntax:
defaultConfig { contentTypesProvided = return [("text/html", html "Hello, World!")] }
Rest Exceptions
data RestException Source #
Re-exports
An HTTP media type, consisting of the type, subtype, and parameters.
HTTP standard method (as defined by RFC 2616, and PATCH which is defined by RFC 5789).
This is the simplest representation of UTC. It consists of the day number, and a time offset from midnight. Note that if a day has a leap second added to it, it will have 86401 seconds.