diff --git a/src/http/lifecycle/Request.ts b/src/http/lifecycle/Request.ts index 225acfd..647b2b2 100644 --- a/src/http/lifecycle/Request.ts +++ b/src/http/lifecycle/Request.ts @@ -39,11 +39,18 @@ export interface HTTPSourceAddress { port: number; } +/** + * Interface describing a container that holds user input data. + */ +export interface DataContainer { + input(key?: string): any +} + /** * A class that represents an HTTP request from a client. */ @Injectable() -export class Request extends ScopedContainer { +export class Request extends ScopedContainer implements DataContainer { /** The cookie manager for the request. */ public readonly cookies: HTTPCookieJar; @@ -170,7 +177,15 @@ export class Request extends ScopedContainer { * Get the value of an input field on the request. Spans multiple input sources. * @param key */ - public input(key: string) { + public input(key?: string) { + if ( !key ) { + return { + ...this.parsedInput, + ...this.query, + ...this.uploadedFiles, + } + } + if ( key in this.parsedInput ) { return this.parsedInput[key] }