mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-06-14 09:29:44 +08:00
31 lines
739 B
JavaScript
31 lines
739 B
JavaScript
/**
|
|
* example custom resource
|
|
*/
|
|
|
|
var Resource = require('deployd/lib/resource')
|
|
, util = require('util')
|
|
, request = require('request');
|
|
|
|
function Proxy(name, options) {
|
|
Resource.apply(this, arguments);
|
|
this.remote = this.config.remote;
|
|
}
|
|
util.inherits(Proxy, Resource);
|
|
module.exports = Proxy;
|
|
|
|
Proxy.prototype.handle = function (ctx, next) {
|
|
if(ctx.req && ctx.req.method !== 'GET') return next();
|
|
var remote = this.remote;
|
|
request.get(remote + ctx.url).pipe(ctx.res);
|
|
};
|
|
|
|
Proxy.label = 'HTTP Proxy';
|
|
Proxy.defaultPath = '/proxy';
|
|
|
|
Proxy.basicDashboard = {
|
|
settings: [{
|
|
name: "remote"
|
|
, type: "text" //"textarea", "number", and "checkbox" work as well
|
|
, description: "The remote server to proxy to."
|
|
}]
|
|
}; |