Add RequestClass to override AppClass
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Garrett Mills 2021-12-16 14:02:15 -06:00
parent 9204a02450
commit b105a61ca2

25
src/http/RequestClass.ts Normal file
View 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()
}
}