Add basic response factories and helpers
This commit is contained in:
17
src/http/response/ResponseFactory.ts
Normal file
17
src/http/response/ResponseFactory.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import {HTTPStatus} from "@extollo/util"
|
||||
import {Instantiable} from "@extollo/di"
|
||||
import {Request} from "../lifecycle/Request"
|
||||
|
||||
export abstract class ResponseFactory {
|
||||
protected targetStatus: HTTPStatus = HTTPStatus.OK
|
||||
|
||||
public async write(request: Request): Promise<Request> {
|
||||
request.response.setStatus(this.targetStatus)
|
||||
return request
|
||||
}
|
||||
|
||||
public status(status: HTTPStatus) {
|
||||
this.targetStatus = status
|
||||
return this
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user