You could use a formatter.
I don't think using a middleware will work. Restify ignores middleware once it finds a proper route handler (.get .put .post etc). You could use a formatter instead. http://restify.com/#content-negotiation
When you make a restify server you can specify formatters. These are invoked after a route handler calls res.send(). This will allow you to manipulate the body before sending it back.
var server = restify.createServer({
formatters: {
'application/foo': function formatFoo(req, res, body, cb) {
// body is what was sent with the response, you can edit it here.
// You finish processing by calling cb(null, body).
// Just be sure that you body is properly stringified.
// See the restify docs above for more information.
}
}
});