hapi-swaggered icon indicating copy to clipboard operation
hapi-swaggered copied to clipboard

Automatically generate HEAD methods (option)

Open grabbou opened this issue 10 years ago • 0 comments

As Hapi.js automatically generates HEAD routes for every GET (and based on GET decides what to return), would be cool to allow displaying them, on:

  • global basis (in plugin config object)
  • per route basis (config.plugins['hapi-swaggered'].displayHead = true) - this should check if route.method === GET and if not, ignore (or let user know he's doing something wrong). If displayHead === false - should overwrite global configuration

Source: https://github.com/hapijs/hapi/issues/795

Especially

HEAD is created automatically for every GET you define

and

If you want to optimize your handling of HEAD requests, simply check your GET handler for the method, and if it is 'head', return an empty response with the correct headers. This is only worth doing for some very expensive GET requests, where you are expecting clients to use HEAD directly.

By spec, no payload allowed.

Authentication is the same so HEAD should inherit all GET properties (scope, authentication scheme, error codes) and so on

grabbou avatar Apr 29 '15 15:04 grabbou