2020-07-28 14:11:48 +00:00
|
|
|
import ResponseFactory from './ResponseFactory.ts'
|
|
|
|
import {Request} from '../Request.ts'
|
|
|
|
|
|
|
|
export default class JSONResponseFactory extends ResponseFactory {
|
|
|
|
constructor(
|
|
|
|
public readonly value: any
|
|
|
|
) {
|
|
|
|
super()
|
|
|
|
}
|
|
|
|
|
|
|
|
public async write(request: Request): Promise<Request> {
|
2020-07-30 03:55:17 +00:00
|
|
|
request = await super.write(request)
|
2020-07-30 03:01:20 +00:00
|
|
|
request.response.headers.set('Content-Type', 'application/json')
|
2020-07-28 14:11:48 +00:00
|
|
|
request.response.body = JSON.stringify(this.value)
|
|
|
|
return request
|
|
|
|
}
|
|
|
|
}
|