imrefazekas / connect-rest

Exceptionally featureful Restful web services middleware for connect node.js
MIT License
100 stars 29 forks source link

Headers have not returning #40

Closed thisroot closed 7 years ago

thisroot commented 7 years ago

Hi i can't tune this package that it return headers. I make as wrote in a guide. But i use it with express, as wrote in Ethan's Brown book.


const apiOptions = {
        context: '',
        domain: require('domain').create()
    };

    apiOptions.domain.on('error', function(err){
        console.log('API domain error.\n', err.stack);
        setTimeout(function(){
            console.log('Server shutting down after API domain error.');
            process.exit(1);
        }, 5000);
        server.close();
        let worker = require('cluster').worker;
        if(worker) worker.disconnect();
    });

    const rest = require('connect-rest').create(apiOptions);

    app.use(rest.processRequest());

.....

    session_start_app: function (req, content, cb) {
       return cb( null,{
           status: '201',
           message:"privet"},
           { headers: {
               ETag: "10c24bc-4ab-457e1c1f"
           } } );
    }
imrefazekas commented 7 years ago

Good catch, thank you. See version @2.12.0 for a fix.