RequestParser Class
The Request Parser takes an IRequest provides parsing and sub request creation \
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
Constructor | Alerts | Description |
---|---|---|
(constructor)(request) | Beta |
Constructs a new instance of the RequestParser class |
Static Methods
Method | Alerts | Return Type | Description |
---|---|---|---|
create(request) | Beta |
RequestParser | |
getPathParts(url) | Beta |
readonly string[] | Splits the path of the url and decodes each path part |
Properties
Property | Alerts | Modifiers | Type | Description |
---|---|---|---|---|
headers | Beta |
optional , readonly |
IRequestHeader | |
pathParts | Beta |
readonly |
readonly string[] | Returns the decoded path parts of the request's url |
query | Beta |
readonly |
string | |
url | Beta |
readonly |
string |
Methods
Method | Alerts | Return Type | Description |
---|---|---|---|
createSubRequest(startingPathIndex) | Beta |
IRequest |
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) | Beta |
boolean | Returns 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
For more information about our API support guarantees, see here.
Signature
protected constructor(request: Readonly<IRequest>);
Parameters
Parameter | Type | Description |
---|---|---|
request | Readonly<IRequest> |
Property Details
headers
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
For more information about our API support guarantees, see here.
Signature
get pathParts(): readonly string[];
Type: readonly string[]
query
For more information about our API support guarantees, see here.
Signature
readonly query: string;
Type: string
url
For more information about our API support guarantees, see here.
Signature
get url(): string;
Type: string
Method Details
create
For more information about our API support guarantees, see here.
Signature
static create(request: Readonly<IRequest>): RequestParser;
Parameters
Parameter | Type | Description |
---|---|---|
request | Readonly<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.
For more information about our API support guarantees, see here.
Signature
createSubRequest(startingPathIndex: number): IRequest;
Parameters
Parameter | Type | Description |
---|---|---|
startingPathIndex | number | The 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
For more information about our API support guarantees, see here.
Signature
static getPathParts(url: string): readonly string[];
Parameters
Parameter | Type | Description |
---|---|---|
url | string | the 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.
For more information about our API support guarantees, see here.
Signature
isLeaf(elements: number): boolean;
Parameters
Parameter | Type | Description |
---|---|---|
elements | number | number of elements in path |
Returns
Return type: boolean