Skip to content

feat(routing)!: the server listens as its config says - #12

Closed
arjendevos wants to merge 5 commits into
feat/queue-poolsfrom
feat/routing-config
Closed

arjendevos wants to merge 5 commits into
feat/queue-poolsfrom
feat/routing-config

Conversation

@arjendevos

@arjendevos arjendevos commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #11.

Routing.Run read HOST, PORT and SHUTDOWN_TIMEOUT from the environment itself, and the health endpoint and trusted platform were options of their own. All of it is now config.Server, handed to routing.WithConfig, as queueing takes config.Queue:

app.WithRouting(
	routing.WithConfig(config.Server{
		Host:            "0.0.0.0",
		Port:            80,
		ShutdownTimeout: 30 * time.Second,
		HealthEndpoint:  "/health",
		TrustedPlatform: gin.PlatformCloudflare,
	}),
	routing.WithRouters(routes.Api),
)
  • WithConfig is required: Run without it fails. Building the engine (Engine(), as tests do) does not need it.
  • Zero values keep the old defaults: an empty host is 0.0.0.0, port 0 is 80, no timeout is 30s.

Breaking: pass routing.WithConfig with what HOST, PORT and SHUTDOWN_TIMEOUT used to say; routing.WithHealth and routing.WithTrustedPlatform are gone, for the config's HealthEndpoint and TrustedPlatform.

Tested: the shutdown test (moved under tests/routing) now listens from the config, and new tests cover Run without one and the health endpoint from the config.

Run read HOST, PORT and SHUTDOWN_TIMEOUT from the environment itself. It
now takes config.Server, handed to routing.WithConfig, which it needs:
without one, Run fails with ErrNoConfig. An empty host is 0.0.0.0, port
0 is 80, and no timeout is 30s, as before.

BREAKING CHANGE: routing.WithConfig is required to Run.
Comment thread routing/options.go Outdated

func WithHealth(endpoint string) Option {
return func(r *Routing) {
r.HealthEndpoint = endpoint

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should be moved to the config the healhtendpoint

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for the trustedplatform etc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to config.Server.HealthEndpoint in 2fe5438; WithHealth is gone.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for config.Server.TrustedPlatform. Whether failed responses show their error went there too (ShowErrors, in #13) instead of a package-level switch.

Comment thread routing/routing.go Outdated
)

// ErrNoConfig is Run without WithConfig.
var ErrNoConfig = errors.New("[routing] no config: pass routing.WithConfig")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont like this being a var

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gone: the error is returned inline, here and in queueing, cache and redis.

Comment thread routing/routing.go Outdated
if h := os.Getenv("HOST"); h != "" {
host = h
host, port := r.Config.Host, r.Config.Port
if host == "" {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iwould do host, port := "0.0.0.0", 80 and then the if r.config.host {}?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, and the shutdown timeout the same way.

… the server config

Both are how the server is set up, like its host and port, so they sit in
config.Server instead of options of their own. The missing config error is
returned inline and the defaults are set before the config overrides them.

Copy link
Copy Markdown
Contributor Author

Folded into #18.

@arjendevos arjendevos closed this Nov 23, 2026
@arjendevos
arjendevos deleted the feat/routing-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