lib/src/http/RequestClass.ts

26 lines
762 B
TypeScript
Raw Normal View History

2021-12-16 20:02:15 +00:00
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()
}
}