Skip to content

feat(app)!: the app runs from its config, not APP_ENV - #13

Closed
arjendevos wants to merge 5 commits into
feat/routing-configfrom
feat/app-config
Closed

arjendevos wants to merge 5 commits into
feat/routing-configfrom
feat/app-config

Conversation

@arjendevos

@arjendevos arjendevos commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #12.

The app (app.New), the scheduler (commands limited with command.Environment) and failed responses (whether they say the error behind them) each read APP_ENV themselves. Now the app takes config.App and hands its environment on:

app.New(config.App, // config.App{Environment: config.ProductionEnvironment, ...}
	app.WithDatabase(db),
	...
)
  • app.New takes config.App first, so an app can't be built without one.
  • The scheduler gets the environment through scheduling.WithEnvironment, which app.WithScheduling passes.
  • Failed responses say the error behind them only when config.Server.ShowErrors says so: routing puts it on each request, where the response reads it, so no state is shared between requests. The app sets it, usually Environment != config.ProductionEnvironment. Unset, they don't, which is the safe side.
  • config/env.helpers.go still reads APP_ENV to pick which .env file to load: that runs before any config exists.

Breaking: app.New takes a config.App as its first argument, and failed responses show their error only with config.Server.ShowErrors.

Tested: tests/scheduling covers a command limited to production in production and staging, whatever APP_ENV says; tests/routing covers a failed response with errors shown and hidden. The app's container test moved under tests/app.

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.

Copy link
Copy Markdown
Contributor Author

Folded into #18.

@arjendevos arjendevos closed this Nov 23, 2026
@arjendevos
arjendevos deleted the feat/app-config branch November 23, 2026 18:20
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.

1 participant