Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
When the HeaderMagnet is formed for a user-defined custom header, it used the class' name to populate the `headerName` field. However, the user may have named their class differently than its name, by excluding dashes, for example. This could produce an incosistency in behavior when routes would generate a `MissingHeaderRejection` for a custom header because the `headerValueByType` directive constructs a `MissingHeaderRejection` with a `headerName` populated from the magnet, which in the case of a custom header, comes from the header's class name rather than its name field. Since the magnet implicits have access to the user-defined header name in the `ModeledCustomHeaderCompanion` object, we should take advantage of it: This change updates the implicit to override the `headerName` behavior by setting it to the companion's `name` field. I considered using an alternate approach of analyzing the class passed into the `ModeledCompanion.nameFromClass` method. However, that required using reflection and potentially had broader side-effects since it would change the underlying behavior of a public trait. Fixes #2487.
- Loading branch information
Showing
3 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters