Closed jy95 closed 6 years ago
Hello,
I just wonder if there is not a possibility to add middleware(s) just before the handler function ...
I tried to mix the 2 osprey middlewares : https://github.com/mulesoft-labs/osprey-resources and https://github.com/mulesoft-labs/osprey-method-handler . It doesn't seem to work together ..
I was thinking about something like that :
var express = require('express'); var resources = require('osprey-resources'); var app = express(); var handler = require('osprey-method-handler') var connect = require('connect'); var router = resources( [{ relativeUri: '/users', methods: [{ method: 'post', body: { 'application/json': { schema: '...' } } }] }], function (method, path) { // the middleware(s) var chain = connect(); var methodType = method.method.toUpperCase(); chain.use(handler(method, path, methodType, {})) return chain; }, function (method, path) { return function (req, res, next) { // the route res.end('hello, world!') } } ); app.use('/v1' , router);
So, any idea ?
Hello,
I just wonder if there is not a possibility to add middleware(s) just before the handler function ...
I tried to mix the 2 osprey middlewares : https://github.com/mulesoft-labs/osprey-resources and https://github.com/mulesoft-labs/osprey-method-handler . It doesn't seem to work together ..
I was thinking about something like that :
So, any idea ?