UNPKG

@hapiness/ng-universal

Version:

This is a Hapiness Engine for running Angular Apps on the server for server side rendering.

75 lines 2.44 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); const core_1 = require("@hapiness/core"); let HttpServerReply = class HttpServerReply { /** * Constructor */ constructor() { this._headers = {}; this._redirectUrl = ''; this._willRedirect = false; } /** * Add new header to the original response * * @param {string} key the header's key * @param {string} value the header's value * * @returns {HttpServerReply} current instance */ header(key, value) { if (!!key && !!value) { this._headers = Object.assign({}, this._headers, { [key]: value }); } return this; } /** * Returns all additional headers for current response */ get headers() { return this._headers; } /** * Set redirect url * * @param {string} url redirection * * @returns {HttpServerReply} current instance */ redirect(url) { if (!url || typeof url !== 'string') { throw new TypeError('argument url must be a string'); } this._redirectUrl = url; this._willRedirect = true; return this; } /** * Returns redirect url value */ get redirectUrl() { return this._redirectUrl; } /** * Returns flag to know if response will be a redirection */ get willRedirect() { return this._willRedirect; } }; HttpServerReply = __decorate([ core_1.Service(), __metadata("design:paramtypes", []) ], HttpServerReply); exports.HttpServerReply = HttpServerReply; //# sourceMappingURL=http-server.reply.js.map