You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lib/src/http/response/HTMLResponseFactory.ts

20 lines
577 B

import {ResponseFactory} from "./ResponseFactory";
import {Request} from "../lifecycle/Request";
export function html(value: string): HTMLResponseFactory {
return new HTMLResponseFactory(value)
}
export class HTMLResponseFactory extends ResponseFactory {
constructor(
public readonly value: string,
) { super() }
public async write(request: Request) {
request = await super.write(request)
request.response.setHeader('Content-Type', 'text/html; charset=utf-8')
request.response.body = this.value
return request
}
}