How to use the http-status.MOVED_PERMANENTLY function in http-status

To help you get started, we’ve selected a few http-status examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / taxinomitis / src / lib / restapi / config.ts View on Github external
app.get('/*', (req, res, next) => {
            if (req.hostname.startsWith('www.')){
                const host: string = req.headers.host as string;

                res.redirect(httpstatus.MOVED_PERMANENTLY,
                            'https://' + host.substr(4) + req.url);
            }
            else {
                next();
            }
        });
    }
github mayo / metalsmith-serve / lib / index.js View on Github external
fileServer.serve(request, response, function(err, res) {
          if (err) {
            if (options.redirects[request.url]) {
              log(chalk.yellow("[" + HTTPStatus.MOVED_PERMANENTLY + "] " + request.url + " > " + options.redirects[request.url]), true);
              response.writeHead(HTTPStatus.MOVED_PERMANENTLY, {"Location": options.redirects[request.url]});
              response.end(HTTPStatus[HTTPStatus.MOVED_PERMANENTLY]);
            }
            else if (err.status && options.http_error_files && options.http_error_files[err.status]) {
              log(chalk.yellow("[" + err.status + "] " + request.url + " - served: " + options.http_error_files[err.status]), true);
              fileServer.serveFile(options.http_error_files[err.status], err.status, {}, request, response);
            }
            else {
              log(chalk.red("[" + err.status + "] " + request.url), true);

              response.writeHead(err.status, err.headers);
              response.end(HTTPStatus[err.status]);
            }

          } else if (options.verbose) {
            log("[" + response.statusCode + "] " + request.url, true);
          }
        });
github mayo / metalsmith-serve / lib / index.js View on Github external
fileServer.serve(request, response, function(err, res) {
          if (err) {
            if (options.redirects[request.url]) {
              log(chalk.yellow("[" + HTTPStatus.MOVED_PERMANENTLY + "] " + request.url + " > " + options.redirects[request.url]), true);
              response.writeHead(HTTPStatus.MOVED_PERMANENTLY, {"Location": options.redirects[request.url]});
              response.end(HTTPStatus[HTTPStatus.MOVED_PERMANENTLY]);
            }
            else if (err.status && options.http_error_files && options.http_error_files[err.status]) {
              log(chalk.yellow("[" + err.status + "] " + request.url + " - served: " + options.http_error_files[err.status]), true);
              fileServer.serveFile(options.http_error_files[err.status], err.status, {}, request, response);
            }
            else {
              log(chalk.red("[" + err.status + "] " + request.url), true);

              response.writeHead(err.status, err.headers);
              response.end(HTTPStatus[err.status]);
            }

          } else if (options.verbose) {
            log("[" + response.statusCode + "] " + request.url, true);