text(text: string, status: number = this._status, headers: Headers = {}): Response {
if (typeof text !== 'string') {
throw new TypeError('text method arg must be a string!')
}
headers['Content-Type'] = 'text/plain'
headers['Content-Type'] ||= 'text/plain; charset=UTF-8'
return this.body(text, status, headers)
}
json(object: object, status: number = this._status, headers: Headers = {}): Response {
if (typeof object !== 'object') {
throw new TypeError('json method arg must be a object!')
}
const body = JSON.stringify(object)
headers['Content-Type'] = 'application/json; charset=UTF-8'
headers['Content-Type'] ||= 'application/json; charset=UTF-8'
return this.body(body, status, headers)
}
html(html: string, status: number = this._status, headers: Headers = {}): Response {
if (typeof html !== 'string') {
throw new TypeError('html method arg must be a string!')
}
headers['Content-Type'] = 'text/html; charset=UTF-8'
headers['Content-Type'] ||= 'text/html; charset=UTF-8'
return this.body(html, status, headers)
}
redirect(location: string, status: number = 302): Response {