Add RequestClass to override AppClass
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9204a02450
commit
b105a61ca2
25
src/http/RequestClass.ts
Normal file
25
src/http/RequestClass.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import {AppClass} from '../lifecycle/AppClass'
|
||||||
|
import {Container, Inject, Injectable} from '../di'
|
||||||
|
import {RequestLocalStorage} from './RequestLocalStorage'
|
||||||
|
import {Request} from './lifecycle/Request'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base for classes that gives access to the global application and request container.
|
||||||
|
*
|
||||||
|
* Similar to AppClass, but provides the Request instead of the Container.
|
||||||
|
*/
|
||||||
|
@Injectable()
|
||||||
|
export class RequestClass extends AppClass {
|
||||||
|
@Inject()
|
||||||
|
protected readonly requestClassStorage!: RequestLocalStorage
|
||||||
|
|
||||||
|
/** Get the request container. **/
|
||||||
|
protected container(): Container {
|
||||||
|
return this.requestClassStorage.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the request. */
|
||||||
|
protected request(): Request {
|
||||||
|
return this.requestClassStorage.get()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user