Skip to main content

HttpTriggerV4Adapter

@h4ad/serverless-adapter > HttpTriggerV4Adapter

(class) HttpTriggerV4Adapter

The adapter to handle requests from Http Trigger on Azure Function V4.

Signature:

export declare class HttpTriggerV4Adapter implements AdapterContract<HttpRequest, Context, HttpResponseSimple> 

Implements: AdapterContract <HttpRequest, Context, HttpResponseSimple>

Example

const stripBasePath = '/any/custom/base/path'; // default ''
const adapter = new HttpTriggerV4Adapter(\{ stripBasePath });

(constructor)

Default constructor

Signature:

constructor(options?: HttpTriggerV4AdapterOptions | undefined);

Parameters

ParameterTypeDescription
optionsHttpTriggerV4AdapterOptions | undefined(Optional) The options to customize the HttpTriggerV4Adapter

(method) canHandle

Signature:

canHandle(event: unknown, context: unknown): boolean;

Parameters

ParameterTypeDescription
eventunknown
contextunknown

Returns:

boolean

(method) getAdapterName

Signature:

getAdapterName(): string;

Returns:

string

(method) getAzureCookiesFromHeaders

Get the Azure Cookie list parsed from set-cookie header.

Signature:

protected getAzureCookiesFromHeaders(headers: BothValueHeaders): Cookie[];

Parameters

ParameterTypeDescription
headersBothValueHeadersThe headers object

Returns:

Cookie[]

(method) getPathFromEvent

Get path from event with query strings

Signature:

protected getPathFromEvent(event: HttpRequest): string;

Parameters

ParameterTypeDescription
eventHttpRequestThe event sent by serverless

Returns:

string

(method) getRequest

Signature:

getRequest(event: HttpRequest): AdapterRequest;

Parameters

ParameterTypeDescription
eventHttpRequest

Returns:

AdapterRequest

(method) getResponse

Signature:

getResponse(\{ body, statusCode, headers: originalHeaders, }: GetResponseAdapterProps<HttpRequest>): HttpResponseSimple;

Parameters

ParameterTypeDescription
{ body, statusCode, headers: originalHeaders, }GetResponseAdapterProps <HttpRequest>

Returns:

HttpResponseSimple

(method) onErrorWhileForwarding

Signature:

onErrorWhileForwarding(\{ error, respondWithErrors, event, delegatedResolver, log, }: OnErrorProps<HttpRequest, HttpResponseSimple>): void;

Parameters

ParameterTypeDescription
{ error, respondWithErrors, event, delegatedResolver, log, }OnErrorProps <HttpRequest, HttpResponseSimple>

Returns:

void

(property) options

Signature:

protected readonly options?: HttpTriggerV4AdapterOptions | undefined;

(method) parseCookie

Parse the string cookie to the Azure Cookie Object. This code was written by @zachabney on this library .

Signature:

protected parseCookie(cookie: string): Cookie;

Parameters

ParameterTypeDescription
cookiestringThe cookie

Returns:

Cookie