HTTP Status Cats on LineRate

Have you seen the HTTP Status Cats? Now there is a Node.js module in NPM that can be used as an Express middleware for setting the X-Status-Cat header, because that is useful! LineRate can also do it. The script below puts the link to the appropriate HTTP Status Cat in the X-Status-Cat header.

var cats = require('http-status-cats').cats;
var vsm = require('lrs/virtualServerModule');

function addRespHandler(req, res, next) {
  next.on('response', function(clires) {
    clires.bindHeaders(res);
    res.setHeader('X-Status-Cat', cats[clires.statusCode]);
    clires.fastPipe(res);
  });
  next();
}

vsm.on('exist', 'vs', function(vs) { vs.on('request', addRespHandler); });

Go ahead and clone my gist. My favorite status code is even included from RFC 2324, 418.

Published Oct 28, 2014
Version 1.0

Was this article helpful?

No CommentsBe the first to comment