Skip to main content

RequestParser Class

The Request Parser takes an IRequest provides parsing and sub request creation

This API is provided for existing users, but is not recommended for new users.

To use, import via @fluidframework/runtime-utils/legacy.

For more information about our API support guarantees, see here.

Signature

export declare class RequestParser implements IRequest

Implements: IRequest

Constructors

ConstructorAlertsDescription
(constructor)(request)BetaConstructs a new instance of the RequestParser class

Static Methods

MethodAlertsReturn TypeDescription
create(request)BetaRequestParser
getPathParts(url)Betareadonly string[]Splits the path of the url and decodes each path part

Properties

PropertyAlertsModifiersTypeDescription
headersBetaoptional, readonlyIRequestHeader
pathPartsBetareadonlyreadonly string[]Returns the decoded path parts of the request's url
queryBetareadonlystring
urlBetareadonlystring

Methods

MethodAlertsReturn TypeDescription
createSubRequest(startingPathIndex)BetaIRequest

Creates a sub request starting at a specific path part of this request's url The sub request url always has a leading slash, and always include query params if original url has any e.g. original url is /a/b/?queryParams, createSubRequest(0) is /a/b/?queryParams createSubRequest(1) is /b/?queryParams createSubRequest(2) is /?queryParams createSubRequest(n) where n is bigger than parts length, e.g. 2, or n is less than 0 will throw an exception

note: query params are not counted towards path parts.

isLeaf(elements)BetabooleanReturns true if it's a terminating path, i.e. no more elements after elements entries and empty query.

Constructor Details

(constructor)

Constructs a new instance of the RequestParser class

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected constructor(request: Readonly<IRequest>);

Parameters

ParameterTypeDescription
requestReadonly<IRequest>

Property Details

headers

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

readonly headers?: IRequestHeader;

Type: IRequestHeader

pathParts

Returns the decoded path parts of the request's url

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

get pathParts(): readonly string[];

Type: readonly string[]

query

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

readonly query: string;

Type: string

url

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

get url(): string;

Type: string

Method Details

create

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

static create(request: Readonly<IRequest>): RequestParser;

Parameters

ParameterTypeDescription
requestReadonly<IRequest>

Returns

Return type: RequestParser

createSubRequest

Creates a sub request starting at a specific path part of this request's url The sub request url always has a leading slash, and always include query params if original url has any e.g. original url is /a/b/?queryParams, createSubRequest(0) is /a/b/?queryParams createSubRequest(1) is /b/?queryParams createSubRequest(2) is /?queryParams createSubRequest(n) where n is bigger than parts length, e.g. 2, or n is less than 0 will throw an exception

note: query params are not counted towards path parts.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

createSubRequest(startingPathIndex: number): IRequest;

Parameters

ParameterTypeDescription
startingPathIndexnumberThe index of the first path part of the sub request

Returns

Return type: IRequest

getPathParts

Splits the path of the url and decodes each path part

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

static getPathParts(url: string): readonly string[];

Parameters

ParameterTypeDescription
urlstringthe url to get path parts of

Returns

Return type: readonly string[]

isLeaf

Returns true if it's a terminating path, i.e. no more elements after elements entries and empty query.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

isLeaf(elements: number): boolean;

Parameters

ParameterTypeDescription
elementsnumbernumber of elements in path

Returns

Return type: boolean