-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support/http/httpdecode: add decoding of path params (#2245)
### What Add decoding of path parameters from requests into structs to the `httpdecode` package in a new `DecodePath` function and into the existing `Decode` function. ### Why We use httpdecode to decode requests into structs and this works really well for JSON and form bodys, but we have the odd endpoint that also has request parameters provided via the path string. An example of this is where an endpoint is for an account. In some situations it might be convenient to use middleware to pick out those path parameters earlier on and provide it in the context. In other situations, which this PR addresses, it can keep our code more succinct if we include those path parameters into the request object that we're decoding the entire request into. The hope is we can take this code into the `support/render/httpjson` package by having that package use `httpdecode.Decode` so that it is possible to capture all the request input in a single object for the handler. This PR is a step towards that but that benefit won't be realized yet. ### Important Note This change includes an update to the version of chi that is in use. Version 4 of chi allows for retrieving the context safely even if it is not present.
- Loading branch information
1 parent
232f455
commit f958201
Showing
5 changed files
with
166 additions
and
8 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
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