nextjs-koa-api / Koa / BaseResponse
Koa.BaseResponse
-
ContextDelegatedResponse
↳
BaseResponse
↳↳
Response
• body: unknown
Get/Set response body.
ContextDelegatedResponse.body
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:321
• etag: string
Get/Set the ETag of a response. This will normalize the quotes if necessary.
this.response.etag = 'md5hashsum';
this.response.etag = '"md5hashsum"';
this.response.etag = 'W/"123456789"';
param
api
public
ContextDelegatedResponse.etag
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:398
• header: OutgoingHttpHeaders
Return response header.
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:602
• headerSent: boolean
Check if a header has been written to the socket.
ContextDelegatedResponse.headerSent
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:332
• headers: OutgoingHttpHeaders
Return response header, alias as response.header
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:607
• lastModified: Date
Get the Last-Modified date in Date form, if it exists. Set the Last-Modified date using a string or a Date.
this.response.lastModified = new Date();
this.response.lastModified = '2013-09-13';
ContextDelegatedResponse.lastModified
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:385
• length: number
Return parsed response Content-Length when present.
Set Content-Length field to n
.
ContextDelegatedResponse.length
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:327
• message: string
Get response status message
ContextDelegatedResponse.message
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:316
• socket: Socket
Return the request socket.
returns
api
public
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:597
• status: number
Get/Set response status code.
ContextDelegatedResponse.status
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:311
• type: string
Return the response mime type void of parameters such as "charset".
Set Content-Type response header with type
through mime.lookup()
when it does not contain a charset.
Examples:
this.type = '.html';
this.type = 'html';
this.type = 'json';
this.type = 'application/json';
this.type = 'png';
ContextDelegatedResponse.type
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:376
• writable: boolean
Checks if the request is writable. Tests for the existence of the socket as node sometimes does not set it.
ContextDelegatedResponse.writable
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:436
▸ append(field
, val
): void
Append additional header field
with value val
.
Examples:
this.append('Link', ['<http://localhost/>', '<http://localhost:3000/>']);
this.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly');
this.append('Warning', '199 Miscellaneous warning');
Name | Type |
---|---|
field |
string |
val |
string | string [] |
void
ContextDelegatedResponse.append
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:424
▸ attachment(filename?
, options?
): void
Set Content-Disposition to "attachment" to signal the client to prompt for download. Optionally specify the filename of the download and some options.
Name | Type |
---|---|
filename? |
string |
options? |
Options |
void
ContextDelegatedResponse.attachment
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:359
▸ flushHeaders(): void
Flush any set headers, and begin the body
void
ContextDelegatedResponse.flushHeaders
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:441
▸ get(field
): string
Return response header. If the header is not set, will return an empty string.
The Referrer
header field is special-cased, both Referrer
and
Referer
are interchangeable.
Examples:
this.get('Content-Type');
// => "text/plain"
this.get('content-type');
// => "text/plain"
this.get('Something');
// => ''
Name | Type |
---|---|
field |
string |
string
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:639
▸ inspect(): any
Inspect implementation.
any
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:644
▸ is(...types
): null
| string
| false
Check whether the response is one of the listed types.
Pretty much the same as this.request.is()
.
api
public
Name | Type |
---|---|
...types |
string [] |
null
| string
| false
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:618
▸ is(types
): null
| string
| false
Name | Type |
---|---|
types |
string [] |
null
| string
| false
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:619
▸ redirect(url
, alt?
): void
Perform a 302 redirect to url
.
The string "back" is special-cased
to provide Referrer support, when Referrer
is not present alt
or "/" is used.
Examples:
this.redirect('back'); this.redirect('back', '/index.html'); this.redirect('/login'); this.redirect('http://google.com');
Name | Type |
---|---|
url |
string |
alt? |
string |
void
ContextDelegatedResponse.redirect
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:353
▸ remove(field
): void
Remove header field
.
Name | Type |
---|---|
field |
string |
void
ContextDelegatedResponse.remove
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:429
▸ set(field
): void
Set header field
to val
, or pass
an object of header fields.
Examples:
this.set('Foo', ['bar', 'baz']); this.set('Accept', 'application/json'); this.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });
Name | Type |
---|---|
field |
Object |
void
ContextDelegatedResponse.set
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:410
▸ set(field
, val
): void
Name | Type |
---|---|
field |
string |
val |
string | string [] |
void
ContextDelegatedResponse.set
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:411
▸ toJSON(): any
Return JSON representation.
any
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:649
▸ vary(field
): void
Vary on field
.
Name | Type |
---|---|
field |
string |
void
ContextDelegatedResponse.vary
node_modules/.pnpm/@types+koa@2.13.4/node_modules/@types/koa/index.d.ts:337