MCPcopy
hub / github.com/eggjs/egg / Response

Class Response

src/app/extend/response.ts:5–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3const REAL_STATUS = Symbol('response realStatus');
4
5export default class Response extends KoaResponse {
6 /**
7 * Get or set a real status code.
8 *
9 * e.g.: Using 302 status redirect to the global error page
10 * instead of show current 500 status page.
11 * And access log should save 500 not 302,
12 * then the `realStatus` can help us find out the real status code.
13 * @member {Number} Response#realStatus
14 * @return {Number} The status code to be set.
15 */
16 get realStatus(): number {
17 if (this[REAL_STATUS]) {
18 return this[REAL_STATUS] as number;
19 }
20 return this.status;
21 }
22
23 /**
24 * Set a real status code.
25 *
26 * e.g.: Using 302 status redirect to the global error page
27 * instead of show current 500 status page.
28 * And access log should save 500 not 302,
29 * then the `realStatus` can help us find out the real status code.
30 * @member {Number} Response#realStatus
31 * @param {Number} status The status code to be set.
32 */
33 set realStatus(status: number) {
34 this[REAL_STATUS] = status;
35 }
36}
37
38declare module '@eggjs/core' {
39 // add Response overrides types

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…