Feature/custom headers (issue #169) #323
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the ability to add custom headers to responses. It follows the steps outlined in #169 except it does not use
var EnvVars = map[string]string{
and instead references the .env variable in theconfig.yaml
, because custom headers need a custom key ('apiKey' for example) and this seemed the most straightforward and user-friendly solution. All tests passed and the lint passed.I'm not sure how to best implement
ApplyCustomHeaders
inroutes.go
. Right now the custom headers attach to every response, which does not seem right. Any direction and help finalizing would be much appreciated!Summary:
This PR adds the ability to include custom headers in server responses, defined in
config.yaml
, and applies them to every response via a new middleware functionApplyCustomHeaders
.Key points:
CustomHeaders
field inServerConfig
struct inconfig/models.go
config.yaml
ApplyCustomHeaders
function inpkg/server/middleware.go
to add custom headers to responsesApplyCustomHeaders
to middleware stack inpkg/server/routes.go
Generated with 鉂わ笍 by ellipsis.dev