egg
Version:
A web application framework for Node.js
35 lines (34 loc) • 1.08 kB
JavaScript
import { Response as Response$1 } from "@eggjs/core";
//#region src/app/extend/response.ts
const REAL_STATUS = Symbol("response realStatus");
var Response = class extends Response$1 {
/**
* Get or set a real status code.
*
* e.g.: Using 302 status redirect to the global error page
* instead of show current 500 status page.
* And access log should save 500 not 302,
* then the `realStatus` can help us find out the real status code.
* @member {Number} Response#realStatus
* @return {Number} The status code to be set.
*/
get realStatus() {
if (this[REAL_STATUS]) return this[REAL_STATUS];
return this.status;
}
/**
* Set a real status code.
*
* e.g.: Using 302 status redirect to the global error page
* instead of show current 500 status page.
* And access log should save 500 not 302,
* then the `realStatus` can help us find out the real status code.
* @member {Number} Response#realStatus
* @param {Number} status The status code to be set.
*/
set realStatus(status) {
this[REAL_STATUS] = status;
}
};
//#endregion
export { Response as default };