25 lines
603 B
TypeScript
25 lines
603 B
TypeScript
import ResponseFactory from './ResponseFactory.ts'
|
|
import {Request} from '../Request.ts'
|
|
|
|
/**
|
|
* Response factory that renders the given value as a string.
|
|
* @return ResponseFactory
|
|
*/
|
|
export default class StringResponseFactory extends ResponseFactory {
|
|
constructor(
|
|
/**
|
|
* Value to be written.
|
|
* @type string
|
|
*/
|
|
public readonly value: string,
|
|
) {
|
|
super()
|
|
}
|
|
|
|
public async write(request: Request): Promise<Request> {
|
|
request = await super.write(request)
|
|
request.response.body = this.value
|
|
return request
|
|
}
|
|
}
|