FaaSHTTPRequest
Hierarchy
- ContextDelegatedRequest
- FaaSHTTPRequest
Index
Properties
accept
body
header
Return request header.
headers
Return request header, alias as request.header
host
Get parsed host from event
hostname
Get parsed host from event
ip
Request remote address.
method
Get request method.
originalUrl
params
Get parsed params
path
Get request pathname.
pathParameters
Get Parsed path parameters from event
query
Get parsed query-string.
url
Get/Set request URL.
Methods
accepts
Check if the given
type(s)is acceptable, returning the best match when true, otherwiseundefined, in which case you should respond with 406 "Not Acceptable".The
typevalue may be a single mime type string such as "application/json", the extension name such as "json" or an array["json", "html", "text/plain"]. When a list or array is given the best match, if any is returned.Examples:
// Accept: text/html
this.accepts('html');
// => "html"
// Accept: text/*, application/json
this.accepts('html');
// => "html"
this.accepts('text/html');
// => "text/html"
this.accepts('json', 'text');
// => "json"
this.accepts('application/json');
// => "application/json"
// Accept: text/*, application/json
this.accepts('image/png');
this.accepts('png');
// => undefined
// Accept: text/*;q=.5, application/json
this.accepts(['html', 'json']);
this.accepts('html', 'json');
// => "json"
acceptsCharsets
Return accepted charsets or best fit based on
charsets.Given
Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5an array sorted by quality is returned:['utf-8', 'utf-7', 'iso-8859-1']
acceptsEncodings
Return accepted encodings or best fit based on
encodings.Given
Accept-Encoding: gzip, deflatean array sorted by quality is returned:['gzip', 'deflate']
acceptsLanguages
Return accepted languages or best fit based on
langs.Given
Accept-Language: en;q=0.8, es, ptan array sorted by quality is returned:['es', 'pt', 'en']
get
Return request header. If the header is not set, will return an empty string.
The
Referrerheader field is special-cased, bothReferrerandRefererare interchangeable.Examples:
this.get('Content-Type');
// => "text/plain"
this.get('content-type');
// => "text/plain"
this.get('Something');
// => ''
is
Check if the incoming request contains the "Content-Type" header field, and it contains any of the give mime
types. If there is no request body,nullis returned. If there is no content type,falseis returned. Otherwise, it returns the firsttypethat matches.Examples:
// With Content-Type: text/html; charset=utf-8
this.is('html'); // => 'html'
this.is('text/html'); // => 'text/html'
this.is('text/*', 'application/json'); // => 'text/html'
// When Content-Type is application/json
this.is('json', 'urlencoded'); // => 'json'
this.is('application/json'); // => 'application/json'
this.is('html', 'application/*'); // => 'application/json'
this.is('html'); // => false
Get parsed request body from event