Skip to content
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

feat!: Used HTTP status codes can be configured #383

Merged
merged 15 commits into from
Dec 17, 2022
Merged

Conversation

dadrus
Copy link
Owner

@dadrus dadrus commented Dec 16, 2022

This PR closes #157 but without offering an option to define custom payloads for error responses in verbose mode. Can't imagine right now, why this could be needed.

This PR does also introduce a breaking change: verbose_errors property is not supported any more in configuration of the services (proxy, decision and management). For the management service it had anyway never an effect and is also not required. The functionality of that property has however not disappeared. It has been moved to yet a new property, available for proxy and decision service configuration and is described below.

Following is implemented by this PR: A new property, named respond has been introduced and can be configured for proxy and the decision service to allow verbose error responses and also to configure mappings for errors/states used internally by heimdall to HTTP response codes, if the defaults implemented by heimdall are not applicable.

Here is an example for the decision service, which turns on verbose errors and maps a couple of HTTP status codes:

serve:
  decision:
    respond:
      verbose: true  # <-- replaces the old verbose_errors property
      with:
       accept:
         code: 200   # <-- default HTTP code used by heimdall is 202
       authorization_error:
         code: 404   # <-- default HHTP code used by heimdall is 401
       authentication_error:
         code: 404   # <-- default HHTP code used by heimdall is 403

@dadrus dadrus changed the title wip: HTTP status codes can be overriden wip: Used HTTP status codes can be configured Dec 16, 2022
@codecov
Copy link

codecov bot commented Dec 16, 2022

Codecov Report

Merging #383 (fa7414b) into main (0b36902) will increase coverage by 0.17%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #383      +/-   ##
==========================================
+ Coverage   86.45%   86.63%   +0.17%     
==========================================
  Files         193      195       +2     
  Lines        7753     7790      +37     
==========================================
+ Hits         6703     6749      +46     
+ Misses        898      890       -8     
+ Partials      152      151       -1     
Impacted Files Coverage Δ
internal/config/serve.go 100.00% <ø> (ø)
internal/handler/management/app.go 73.68% <ø> (-1.32%) ⬇️
internal/fiber/middleware/errorhandler/defaults.go 100.00% <100.00%> (ø)
...nal/fiber/middleware/errorhandler/error_handler.go 100.00% <100.00%> (+7.69%) ⬆️
internal/fiber/middleware/errorhandler/options.go 100.00% <100.00%> (ø)
internal/handler/decision/app.go 78.26% <100.00%> (+5.28%) ⬆️
internal/handler/decision/handler.go 93.18% <100.00%> (+0.49%) ⬆️
internal/handler/proxy/app.go 78.72% <100.00%> (+5.03%) ⬆️
internal/handler/requestcontext/request_context.go 80.28% <100.00%> (ø)
... and 1 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dadrus dadrus changed the title wip: Used HTTP status codes can be configured feat!: Used HTTP status codes can be configured Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the mapping from errors used internally to the HTTP errors configurable
1 participant