Repository navigation
feat(app)!: the app runs from its config, not APP_ENV - #13
Closed
arjendevos wants to merge 5 commits into
Closed
arjendevos wants to merge 5 commits into
arjendevos wants to merge 5 commits into
Conversation
The app, the scheduler and failed responses each read APP_ENV from the environment. app.New now takes config.App first, so an app cannot be built without one, and hands its environment on: to the scheduler, for commands limited to some environments, and to responses, which say the error behind a failure outside production only (response.ShowErrors). BREAKING CHANGE: app.New takes a config.App as its first argument.
… show their error A package-level switch set by app.New was state every request shared. config.Server.ShowErrors now goes on each request's context, where the response reads it, so the app decides it with the rest of the server.
Contributor
Author
|
Folded into #18. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #12.
The app (
app.New), the scheduler (commands limited withcommand.Environment) and failed responses (whether they say the error behind them) each readAPP_ENVthemselves. Now the app takesconfig.Appand hands its environment on:app.Newtakesconfig.Appfirst, so an app can't be built without one.scheduling.WithEnvironment, whichapp.WithSchedulingpasses.config.Server.ShowErrorssays so: routing puts it on each request, where the response reads it, so no state is shared between requests. The app sets it, usuallyEnvironment != config.ProductionEnvironment. Unset, they don't, which is the safe side.config/env.helpers.gostill readsAPP_ENVto pick which.envfile to load: that runs before any config exists.Breaking:
app.Newtakes aconfig.Appas its first argument, and failed responses show their error only withconfig.Server.ShowErrors.Tested:
tests/schedulingcovers a command limited to production in production and staging, whateverAPP_ENVsays;tests/routingcovers a failed response with errors shown and hidden. The app's container test moved undertests/app.