Documentation
¶
Overview ¶
Package nethttp provides a production-ready net/http adapter for go-trpc with configurable timeouts and graceful shutdown support.
Usage:
r := router.NewRouter()
srv := nethttp.NewServer(r, nethttp.Config{Addr: ":8080"})
go srv.Start()
// ...
srv.Shutdown(context.Background())
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Addr string // listen address, default ":8080"
BasePath string // tRPC base path, default "/trpc"
ReadTimeout time.Duration // default 30s
WriteTimeout time.Duration // default 30s
IdleTimeout time.Duration // default 120s
}
Config configures the HTTP server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps a go-trpc Router in a production-ready *http.Server.
func (*Server) Shutdown ¶
Shutdown gracefully shuts down the server, waiting for in-flight requests to complete before returning.
Click to show internal directories.
Click to hide internal directories.