Add support for middleware
This commit is contained in:
@@ -20,6 +20,7 @@ export class Response {
|
||||
private _sentHeaders: boolean = false
|
||||
private _responseEnded: boolean = false
|
||||
private _status: HTTPStatus = HTTPStatus.OK
|
||||
private _blockingWriteback: boolean = false
|
||||
public body: string = ''
|
||||
public readonly sending$: BehaviorSubject<Response> = new BehaviorSubject<Response>()
|
||||
public readonly sent$: BehaviorSubject<Response> = new BehaviorSubject<Response>()
|
||||
@@ -88,6 +89,18 @@ export class Response {
|
||||
return this._sentHeaders
|
||||
}
|
||||
|
||||
public hasBody() {
|
||||
return !!this.body
|
||||
}
|
||||
|
||||
public blockingWriteback(set?: boolean) {
|
||||
if ( typeof set !== 'undefined' ) {
|
||||
this._blockingWriteback = set
|
||||
}
|
||||
|
||||
return this._blockingWriteback
|
||||
}
|
||||
|
||||
public async write(data: any) {
|
||||
return new Promise<void>((res, rej) => {
|
||||
if ( !this._sentHeaders ) this.sendHeaders()
|
||||
|
||||
Reference in New Issue
Block a user