Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
9b6608418b
|
12
CHANGELOG.md
12
CHANGELOG.md
@@ -5,6 +5,17 @@ All notable changes to this module will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this module adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this module adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [1.0.2] - 2026-05-12
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- `Config.ShutdownTimeout time.Duration` (`SERVER_SHUTDOWN_TIMEOUT`, default `10s`) — configures the graceful-shutdown deadline passed to `http.Server.Shutdown`. Previously hardcoded to 10 seconds; callers that serve long-running requests (uploads, streaming) or prefer a shorter fail-fast window can now set this per environment.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `launcher` and `logz` dependencies bumped from v0.9.0 to v1.0.1.
|
||||||
|
- `go` directive updated from 1.25 to 1.26.
|
||||||
|
|
||||||
## [0.9.2] - 2026-03-25
|
## [0.9.2] - 2026-03-25
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -44,6 +55,7 @@ and this module adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.
|
|||||||
- No middleware is installed by default; the full middleware stack is composed explicitly via `WithMiddleware` at construction time, keeping the stack visible and ordering unambiguous in the application source
|
- No middleware is installed by default; the full middleware stack is composed explicitly via `WithMiddleware` at construction time, keeping the stack visible and ordering unambiguous in the application source
|
||||||
- chi was chosen as the underlying router because it uses stdlib `http.Handler` throughout, making it fully compatible with `httpmw` middleware and `httputil` handler adapters without any wrapper code at the boundary
|
- chi was chosen as the underlying router because it uses stdlib `http.Handler` throughout, making it fully compatible with `httpmw` middleware and `httputil` handler adapters without any wrapper code at the boundary
|
||||||
|
|
||||||
|
[1.0.2]: https://code.nochebuena.dev/go/httpserver/releases/tag/v1.0.2
|
||||||
[0.9.2]: https://code.nochebuena.dev/go/httpserver/releases/tag/v0.9.2
|
[0.9.2]: https://code.nochebuena.dev/go/httpserver/releases/tag/v0.9.2
|
||||||
[0.9.1]: https://code.nochebuena.dev/go/httpserver/releases/tag/v0.9.1
|
[0.9.1]: https://code.nochebuena.dev/go/httpserver/releases/tag/v0.9.1
|
||||||
[0.9.0]: https://code.nochebuena.dev/go/httpserver/releases/tag/v0.9.0
|
[0.9.0]: https://code.nochebuena.dev/go/httpserver/releases/tag/v0.9.0
|
||||||
|
|||||||
6
go.mod
6
go.mod
@@ -1,10 +1,10 @@
|
|||||||
module code.nochebuena.dev/go/httpserver
|
module code.nochebuena.dev/go/httpserver
|
||||||
|
|
||||||
go 1.25
|
go 1.26
|
||||||
|
|
||||||
require (
|
require (
|
||||||
code.nochebuena.dev/go/launcher v0.9.0
|
code.nochebuena.dev/go/launcher v1.0.1
|
||||||
github.com/go-chi/chi/v5 v5.2.1
|
github.com/go-chi/chi/v5 v5.2.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require code.nochebuena.dev/go/logz v0.9.0 // indirect
|
require code.nochebuena.dev/go/logz v1.0.1 // indirect
|
||||||
|
|||||||
8
go.sum
8
go.sum
@@ -1,6 +1,6 @@
|
|||||||
code.nochebuena.dev/go/launcher v0.9.0 h1:dJHonA9Xm03AQKK0919FJaQn9ZKHZ+RZfB9yxjnx3TA=
|
code.nochebuena.dev/go/launcher v1.0.1 h1:hbPV8jNtyxfchrT7igzz3M2tKGI3bm8uWkHBXRvSPgg=
|
||||||
code.nochebuena.dev/go/launcher v0.9.0/go.mod h1:IBtntmbnyddukjEhxlc7Ysdzz9nZsnd9+8FzAIHt77g=
|
code.nochebuena.dev/go/launcher v1.0.1/go.mod h1:1KwndVuqm31JN9Dpl9YvOmlogPlKKzoDMo9aRFkYwmM=
|
||||||
code.nochebuena.dev/go/logz v0.9.0 h1:wfV7vtI4V/8ED7Hm31Fbql7Y5iOGrlHN4X8Z5ajTZZE=
|
code.nochebuena.dev/go/logz v1.0.1 h1:kK9aZo19L208CwCr2D/dbSOMaOv62cXsigMSsdFu+8Y=
|
||||||
code.nochebuena.dev/go/logz v0.9.0/go.mod h1:qODhSbKb+tWE7rdhHLcKweiP5CgwIaWoZxadCT3bQV8=
|
code.nochebuena.dev/go/logz v1.0.1/go.mod h1:YNpNm03fURm2v0ySh/477z9AJhtfRcd9rFOW6fFqgNM=
|
||||||
github.com/go-chi/chi/v5 v5.2.1 h1:KOIHODQj58PmL80G2Eak4WdvUzjSJSm0vG72crDCqb8=
|
github.com/go-chi/chi/v5 v5.2.1 h1:KOIHODQj58PmL80G2Eak4WdvUzjSJSm0vG72crDCqb8=
|
||||||
github.com/go-chi/chi/v5 v5.2.1/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=
|
github.com/go-chi/chi/v5 v5.2.1/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=
|
||||||
|
|||||||
@@ -21,11 +21,12 @@ type Logger interface {
|
|||||||
|
|
||||||
// Config holds the HTTP server configuration.
|
// Config holds the HTTP server configuration.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Host string `env:"SERVER_HOST" envDefault:"0.0.0.0"`
|
Host string `env:"SERVER_HOST" envDefault:"0.0.0.0"`
|
||||||
Port int `env:"SERVER_PORT" envDefault:"8080"`
|
Port int `env:"SERVER_PORT" envDefault:"8080"`
|
||||||
ReadTimeout time.Duration `env:"SERVER_READ_TIMEOUT" envDefault:"5s"`
|
ReadTimeout time.Duration `env:"SERVER_READ_TIMEOUT" envDefault:"5s"`
|
||||||
WriteTimeout time.Duration `env:"SERVER_WRITE_TIMEOUT" envDefault:"10s"`
|
WriteTimeout time.Duration `env:"SERVER_WRITE_TIMEOUT" envDefault:"10s"`
|
||||||
IdleTimeout time.Duration `env:"SERVER_IDLE_TIMEOUT" envDefault:"120s"`
|
IdleTimeout time.Duration `env:"SERVER_IDLE_TIMEOUT" envDefault:"120s"`
|
||||||
|
ShutdownTimeout time.Duration `env:"SERVER_SHUTDOWN_TIMEOUT" envDefault:"10s"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// serverOpts holds functional options.
|
// serverOpts holds functional options.
|
||||||
@@ -125,7 +126,11 @@ func (s *httpServer) OnStop() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
s.logger.Info("httpserver: shutting down gracefully")
|
s.logger.Info("httpserver: shutting down gracefully")
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
timeout := s.cfg.ShutdownTimeout
|
||||||
|
if timeout == 0 {
|
||||||
|
timeout = 10 * time.Second
|
||||||
|
}
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
return s.srv.Shutdown(ctx)
|
return s.srv.Shutdown(ctx)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user