Help us shape the future of Go! Take the 2026 Go Developer Survey

server

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package server 提供基于 gin 的 HTTP 服务启动、信号处理与优雅关闭能力。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Server)

Option Server 可选配置。

func WithShutdownTimeout

func WithShutdownTimeout(d time.Duration) Option

WithShutdownTimeout 设置优雅关闭超时时间,默认 5s。

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server HTTP 服务。

func New

func New(cfg config.ServerConfig, handler *gin.Engine, log logger.Logger, opts ...Option) *Server

New 创建 HTTP 服务。

func (*Server) Run

func (s *Server) Run()

Run 启动服务并阻塞,直到收到 SIGINT 或 SIGTERM 后优雅关闭。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL