Query attributes of the HTTP request.
An HTTP request.
HTTP request method.
-- to use shorthand notation
import Serverless.Conn.Request exposing (Method(..))
Request scheme (a.k.a. protocol).
-- to use shorthand notation
import Serverless.Conn.Request exposing (Scheme(..))
These attributes are typically involved in routing requests. See the Routing Demo for an example.
url : Request -> String
The requested URL if it parsed correctly.
method : Request -> Method
HTTP request method.
case Request.method req of
Request.GET ->
-- handle get...
Request.POST ->
-- handle post...
_ ->
-- method not supported...
path : Request -> String
Request path.
While you can access this attribute directly, it is better to provide a
parseRoute
function to the framework.
queryString : Request -> String
The original query string.
While you can access this attribute directly, it is better to provide a
parseRoute
function to the framework.
Functions to access the request body and attempt a cast to a content type. See the Forms Demo for an example.
body : Request -> Serverless.Conn.Body.Body
Request body.
header : String -> Request -> Maybe String
Get a request header by name.
Headers are normalized such that the keys are always lower-case
.
query : String -> Request -> Maybe String
Get a query argument by name.
endpoint : Request -> ( Scheme, String, Basics.Int )
Describes the server endpoint to which the request was made.
( scheme, host, port_ ) =
Request.endpoint req
scheme
is either Request.Http
or Request.Https
host
is the hostname as taken from the "host"
request headerport_
is the port, for example 80
or 443
stage : Request -> String
Serverless deployment stage.
See https://serverless.com/framework/docs/providers/aws/guide/deploying/
methodToString : Method -> String
Gets the HTTP Method as a String, like 'GET', 'PUT', etc.
These functions are typically not needed when building an application. They are used internally by the framework. They may be useful when debugging or writing unit tests.
init : Request
Initialize an empty Request.
Exposed for unit testing. Incoming connections initialize requests using JSON decoders.
decoder : Json.Decode.Decoder Request
JSON decoder for HTTP requests.
methodDecoder : Json.Decode.Decoder Method
JSON decoder for the HTTP request method.
schemeDecoder : Json.Decode.Decoder Scheme
JSON decoder for the request scheme (a.k.a. protocol)