franciscop / server

:desktop_computer: Simple and powerful server for Node.js
https://serverjs.io/
MIT License
3.56k stars 170 forks source link

Support HEAD request method #109

Closed justinpage closed 5 years ago

justinpage commented 5 years ago

What are you trying to do? We use New Relic for monitoring our applications. I noticed that HEAD request to our application fails. What is the easiest path in supporting HEAD request. My understanding is that express supports HEAD by means of GET but maybe with this package, we have to be more explicit

Ask your question How do we support HEAD request to the root of our application. Do we simply add logic to one of our middlewares to check if the method request is HEAD:

ctx.method.toLowerCase() === 'head' ? 200 : false

Returning 200 when request method is HEAD otherwise false which would move on to other middleware.

Wanted to double check if this was the easiest solution to this problem.

franciscop commented 5 years ago

That sounds about right from the source code 👌

Please let me know if you have any issues with this, I'll leave it open for a couple of days