daton/lib/src/http/response/HTMLResponseFactory.ts

18 lines
490 B
TypeScript

import ResponseFactory from './ResponseFactory.ts'
import {Request} from '../Request.ts'
export default class HTMLResponseFactory extends ResponseFactory {
constructor(
public readonly value: string,
) {
super()
}
public async write(request: Request): Promise<Request> {
request = await super.write(request)
request.response.headers.set('Content-Type', 'text/html')
request.response.body = this.value
return request
}
}