IResponse
the response object inherits from http.ServerResponse
Usage#
status#
status(code: number): IResponse#
set response status code
contentType#
contentType(type: string): IResponse#
set response content type
header#
header(key: string, value: string): IResponse#
set(key: string, value: string): IResponse#
set response header
cache#
res.cache(seconds: number): IResponse#
set Cache-Control header in seconds
gzip#
gzip(): IResponse#
compress the response with gzip and set Content-Encoding header to gzip
redirect#
redirect(path: string): void#
redirect the request to new path
cookie#
cookie(key: string, value: any, options?: cookie.CookieSerializeOptions): IResponse#
sets cookie name to value. The value parameter may be a string or object converted to JSON.
clearCookie#
clearCookie(key: string, options?: cookie.CookieSerializeOptions): IResponse#
clears the cookie specified by name.
cache#
cache(seconds: number)#
add Cache-Control header
json#
json(obj: object)#
sends a JSON response.
jsonp#
jsonp(obj: object)#
Sends a JSON response with JSONP support. This method is identical to res.json(), except that it opts-in to JSONP callback support
send#
send(data?: string | Buffer| object)#
send data response