hapijs / h2o2

Proxy handler for hapi.js
Other
165 stars 66 forks source link

Proxy validation allows invalid combination of keys. #116

Closed antony closed 4 years ago

antony commented 4 years ago

Support plan

Community

No

No

Context

What are you trying to achieve or the steps to reproduce?

The documentation states that you can't combine onResponse and uri. However, if you do, you are not warned.

This differs to combining mapUri and uri which causes a validation error.

The net result is you can end up with config which doesn't work, and doesn't error.

const route = {
  method: 'GET',
  path: '/support/{param*}',
  handler: {
    proxy: {
      onResponse: function (err, res, request, h, settings, ttl) {
        ...
      },
      uri: 'https://example.com/{param}'
    }
  }
}

What was the result you got?

No error

What result did you expect?

A validation error to let me know I can't combine uri + onResponse

hueniverse commented 4 years ago

It is not about onResponse and uri but about the combination of onResponse, mapUri, and uri. It is listed in a specific section, not in the options definitions.