New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature query headers #482

Merged
merged 2 commits into from Aug 16, 2018

Conversation

Projects
None yet
2 participants
@eduardoboucas
Copy link
Member

eduardoboucas commented Aug 16, 2018

This PR adds support for feature queries using custom headers.

When a client application wishes to know whether an API instance supports a particular feature, it sends a X-DADI-Requires header with a list of required feature codes, separated by a semicolon. When this header is present, API will go through the feature codes supplied and check which ones it supports. These will be sent back in the response as a X-DADI-Supports header, also separated by semicolons.

Each version of API will ship with its own list of supported feature codes, stored in a features.json file at the root level.

This behaviour is enabled by default, but can be switched off by setting the featureQuery.enabled config property to false.

Example request

GET /version/db/collection

Accept: application/json
Authorization: Bearer 123456789
X-DADI-Requires: aclv1;mediav2

Example response

Content-Type: application/json
X-DADI-Supports: aclv1

{
  "results": (...)
}

In the above example, the consumer application states it requires the aclv1 and mediav2 features. The version of this particular API instance supports aclv1 but not mediav2, so it responds with aclv1 only. At this point, the consumer application knows the subset of features supported by the API and can act accordingly.

@eduardoboucas eduardoboucas requested a review from jimlambie Aug 16, 2018

@eduardoboucas eduardoboucas merged commit 721d370 into develop Aug 16, 2018

4 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls First build on feature/feature-query at 89.685%
Details
security/snyk - package.json (DADI) No new issues
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment