javascript - Hapijs onPreResponse, forwarded response -


for api need have md5 result routes, use:

server.ext('onpreresponse', function(request, reply) {     var content = request.response.source;     var code = request.response.statuscode;      if(typeof request.headers.md5 != 'undefined' && code == 200) {         content = md5(content);     }      if(!debug && code != 200){         content = "error";     }     reply(content).code(code); }); 

when response 404 error, request.response doesn't have response.statuscode... can handle with:

if(typeof code == 'undefined'){     code = 404; } 

but when try view documentation generated lout, have this: some html code

how can forward code message?

you want use reply.continue() rather reply().code()

a similar question answered here: https://github.com/hapijs/discuss/issues/103


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -