server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 10 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 Config added in v0.0.9

type Config struct {
	Host string
	Port int
}

Config 服务配置

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, 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