feat: add request parsing related interfaces

This commit is contained in:
Joachim Van Herwegen 2020-06-10 11:38:39 +02:00
parent e0d74fd68a
commit 70af46933b
6 changed files with 43 additions and 2 deletions

View File

@ -0,0 +1,5 @@
import { AsyncHandler } from '../../util/AsyncHandler';
import { HttpRequest } from '../../server/HttpRequest';
import { Representation } from '../representation/Representation';
export abstract class BodyParser extends AsyncHandler<HttpRequest, Representation> {}

View File

@ -0,0 +1,5 @@
import { AsyncHandler } from '../../util/AsyncHandler';
import { HttpRequest } from '../../server/HttpRequest';
import { RepresentationPreferences } from '../representation/RepresentationPreferences';
export abstract class PreferenceParser extends AsyncHandler<HttpRequest, RepresentationPreferences> {}

View File

@ -0,0 +1,5 @@
import { AsyncHandler } from '../../util/AsyncHandler';
import { HttpRequest } from '../../server/HttpRequest';
import { ResourceIdentifier } from '../representation/ResourceIdentifier';
export abstract class TargetExtractor extends AsyncHandler<HttpRequest, ResourceIdentifier> {}

View File

@ -0,0 +1,13 @@
/**
* Represents a single preference in a request.
*/
export interface RepresentationPreference {
/**
* The actual preference value.
*/
value: string;
/**
* How important this preference is in a value going from 0 to 1.
*/
weight?: number;
}

View File

@ -1,4 +1,12 @@
import { RepresentationPreference } from './RepresentationPreference';
/**
* Contains the preferences of which kind of representation is requested.
*/
export interface RepresentationPreferences {}
export interface RepresentationPreferences {
type?: RepresentationPreference[];
charset?: RepresentationPreference[];
datetime?: RepresentationPreference[];
encoding?: RepresentationPreference[];
language?: RepresentationPreference[];
}

View File

@ -1,4 +1,9 @@
/**
* The unique identifier of a resource.
*/
export interface ResourceIdentifier {}
export interface ResourceIdentifier {
/**
* Path to the relevant resource. Usually this would be an URL.
*/
path: string;
}