Documentation ¶
Index ¶
- Variables
- type Graceful
- func (g *Graceful) Close()
- func (g *Graceful) Run(addr ...string) error
- func (g *Graceful) RunFd(fd uintptr) error
- func (g *Graceful) RunListener(listener net.Listener) error
- func (g *Graceful) RunTLS(addr, certFile, keyFile string) error
- func (g *Graceful) RunUnix(file string) error
- func (g *Graceful) RunWithContext(ctx context.Context) error
- func (g *Graceful) Shutdown(ctx context.Context) error
- func (g *Graceful) Start() error
- func (g *Graceful) Stop() error
- type Option
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyStarted = errors.New("already started router")
ErrAlreadyStarted is returned when trying to start a router that has already been started
var ErrNotStarted = errors.New("router not started")
ErrNotStarted is returned when trying to stop a router that has not been started
Functions ¶
This section is empty.
Types ¶
type Graceful ¶
Graceful is a wrapper around a gin.Engine that provides graceful shutdown
func Default ¶
Default returns a Graceful gin instance with the Logger and Recovery middleware already attached.
func (*Graceful) Close ¶
func (g *Graceful) Close()
Close gracefully shuts down the server. It first shuts down the server using the Shutdown method, then it performs any cleanup operations registered with the server. Finally, it resets the server's internal state.
func (*Graceful) Run ¶
Run attaches the router to a http.Server and starts listening and serving HTTP requests.
func (*Graceful) RunFd ¶
RunFd attaches the router to a http.Server and starts listening and serving HTTP requests through the specified file descriptor.
func (*Graceful) RunListener ¶
RunListener attaches the router to a http.Server and starts listening and serving HTTP requests through the specified net.Listener
func (*Graceful) RunTLS ¶
RunTLS attaches the router to a http.Server and starts listening and serving HTTPS (secure) requests.
func (*Graceful) RunUnix ¶
RunUnix attaches the router to a http.Server and starts listening and serving HTTP requests through the specified unix socket (i.e. a file).
func (*Graceful) RunWithContext ¶
RunWithContext attaches the router to the configured http.Server (fallback to configuring one on :8080 if none are configured) and starts listening and serving HTTP requests. If the passed context is canceled, the server is gracefully shut down
func (*Graceful) Shutdown ¶
Shutdown gracefully shuts down the server without interrupting any active connections.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option specifies instrumentation configuration options.
func WithListener ¶
WithListener configure a http.Server to listen on the given net.Listener.