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

Parameter

Type

Description

options

HttpTriggerV4AdapterOptions | undefined

(Optional) The options to customize the HttpTriggerV4Adapter

(method) canHandle

Signature:

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

Parameters

Parameter

Type

Description

event

unknown

context

unknown

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

Parameter

Type

Description

headers

BothValueHeaders

The headers object

Returns:

Cookie[]

(method) getPathFromEvent

Get path from event with query strings

Signature:

protected getPathFromEvent(event: HttpRequest): string;

Parameters

Parameter

Type

Description

event

HttpRequest

The event sent by serverless

Returns:

string

(method) getRequest

Signature:

getRequest(event: HttpRequest): AdapterRequest;

Parameters

Parameter

Type

Description

event

HttpRequest

Returns:

AdapterRequest

(method) getResponse

Signature:

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

Parameters

Parameter

Type

Description

{ body, statusCode, headers: originalHeaders, }

GetResponseAdapterProps <HttpRequest>

Returns:

HttpResponseSimple

(method) onErrorWhileForwarding

Signature:

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

Parameters

Parameter

Type

Description

{ 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

Parameter

Type

Description

cookie

string

The cookie

Returns:

Cookie