Skip to content

Commit

Permalink
feat: add request parsing related interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimvh committed Jun 17, 2020
1 parent e0d74fd commit 70af469
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/ldp/http/BodyParser.ts
Original file line number Diff line number Diff line change
@@ -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> {}
5 changes: 5 additions & 0 deletions src/ldp/http/PreferenceParser.ts
Original file line number Diff line number Diff line change
@@ -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> {}
5 changes: 5 additions & 0 deletions src/ldp/http/TargetExtractor.ts
Original file line number Diff line number Diff line change
@@ -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> {}
13 changes: 13 additions & 0 deletions src/ldp/representation/RepresentationPreference.ts
Original file line number Diff line number Diff line change
@@ -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;
}
10 changes: 9 additions & 1 deletion src/ldp/representation/RepresentationPreferences.ts
Original file line number Diff line number Diff line change
@@ -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[];
}
7 changes: 6 additions & 1 deletion src/ldp/representation/ResourceIdentifier.ts
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 70af469

Please sign in to comment.