-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
I cannot figure how to include functions in the configuration for fittings. Using CORS as example I'd like to provide the origin
as a function and the only way to do this now is to duplicate the cors fitting in my project's fittings folder like this:
'use strict';
const debug = require('debug')('swagger:cors');
const CORS = require('cors');
// config options: https://www.npmjs.com/package/cors
const options = {
origin: function() {
....
}
};
module.exports = function create(fittingDef, bagpipes) {
debug('config: %j', fittingDef);
const middleware = CORS(Object.assign({}, fittingDef, options));
return function cors(context, cb) {
debug('exec');
middleware(context.request, context.response, cb);
};
};
What I'd love to be able to just specify the function in Swagger's config.xml :
bagpipes:
...
cors:
name: cors
origin: <Some way to reference the function>
Thank you.
Metadata
Metadata
Assignees
Labels
No labels