restify + use() method - never call

147 views Asked by At

I try use "use()" method of Restify like that:

...
server = Restify.createServer(@options)
        server.use(Restify.queryParser())
        server.use(Restify.urlEncodedBodyParser())
        server.use(Restify.CORS())
        server.use( (req, res, next) ->
            console.log('TEST')
            next()
        )
server.listen() ... etc.

But "TEST" will never happen :(

@options is my local variable:

@options.name = 'test-server'
@options.version = '0.0.1'
@options.host ?= @options.host || '0.0.0.0'
@options.listenPort ?= @options.port || process.env.PORT  || 5000
@options.accept = [
     'text/html',
]

@formatter = new Formatter(@options)
@options.formatters = {
    # supported output
    'text/html': @formatter.html,
    # unsupported output
   '*/*': @formatter.error
}
1

There are 1 answers

1
user14763129 On BEST ANSWER

I have a solution... must be defined some routes like:

get(path, callback)
head(path, callback)
post(path, object, callback)
put(path, object, callback)
or
del(path, callback)