Include request parameters in input(...) sources; bump version

This commit is contained in:
2022-03-30 15:35:09 -05:00
parent 153f8f7685
commit 467721f775
2 changed files with 16 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ import * as url from 'url'
import {Response} from './Response'
import * as Negotiator from 'negotiator'
import {HTTPError} from '../HTTPError'
import {ActivatedRoute} from '../routing/ActivatedRoute'
/**
* Enumeration of different HTTP verbs.
@@ -177,20 +178,25 @@ export class Request extends ScopedContainer implements DataContainer {
* @param key
*/
public input(key?: string): unknown {
if ( !key ) {
return {
...this.parsedInput,
...this.query,
...this.uploadedFiles,
let sources = {
...this.parsedInput,
...this.query,
...this.uploadedFiles,
}
if ( this.hasKey(ActivatedRoute) ) {
sources = {
...sources,
...this.make<ActivatedRoute<unknown, unknown[]>>(ActivatedRoute).params,
}
}
if ( key in this.parsedInput ) {
return this.parsedInput[key]
if ( !key ) {
return sources
}
if ( key in this.query ) {
return this.query[key]
if ( key in sources ) {
return sources[key]
}
}