@glandjs/http
Version:
A protocol adapter for HTTP built on top of the Gland architecture solution.
25 lines (24 loc) • 799 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpContext = void 0;
const core_1 = require("@glandjs/core");
const toolkit_1 = require("@medishn/toolkit");
class HttpContext extends core_1.Context {
constructor(events, req, res) {
const broker = events;
super(broker);
this.events = events;
this.req = req;
this.res = res;
this.params = {};
}
throw(status, options) {
const exception = new toolkit_1.HttpException(status, options);
this.status(exception.status);
if (!this.getHeader("content-type")) {
this.setHeader("content-type", "application/json");
}
return this.send(exception.getProblemDetails());
}
}
exports.HttpContext = HttpContext;