Skip to content

Instantly share code, notes, and snippets.

@dallonf
Created November 5, 2012 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dallonf/4017818 to your computer and use it in GitHub Desktop.
Save dallonf/4017818 to your computer and use it in GitHub Desktop.
Rewrite Resource
var Resource = require('deployd/lib/resource')
, util = require('util');
function Rewrite(name, options) {
Resource.apply(this, arguments);
this.rewriteUrl = this.config.rewriteUrl || '/index.html';
}
util.inherits(Rewrite, Resource);
module.exports = Rewrite;
Rewrite.basicDashboard = {
settings: [{
name: 'rewriteUrl'
, type: 'text'
}]
};
Rewrite.prototype.handle = function (ctx, next) {
if(ctx.method !== 'GET' || ctx.req.internal) return next();
ctx.req.url = this.rewriteUrl;
next();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment