web

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrCodeHandler

func ErrCodeHandler(c *gin.Context)

func FlagSet

func FlagSet(defaultPort int) *pflag.FlagSet

func RequestID added in v0.1.1

func RequestID(c *gin.Context) string

func VersionHandler

func VersionHandler(info *Info) gin.HandlerFunc

func ZapRequestID added in v0.1.1

func ZapRequestID(c *gin.Context) zap.Field

Types

type Config

type Config struct {
	Prefix   string `json:"prefix" yaml:"prefix" default:"/"`
	Endpoint string `json:"endpoint" yaml:"endpoint"`
	Host     string `json:"host" yaml:"host" default:"127.0.0.1"`
	Port     int    `json:"port" yaml:"port"`
	Debug    bool   `json:"debug" yaml:"debug"`
	Pprof    bool   `json:"pprof" yaml:"pprof"`
}

func (*Config) Addr

func (c *Config) Addr() string

func (*Config) FlagSet

func (c *Config) FlagSet(defaultPort int) *pflag.FlagSet

func (*Config) GetEndpoint

func (c *Config) GetEndpoint() string

func (*Config) WithDebug

func (s *Config) WithDebug(v bool) *Config

func (*Config) WithEndpoint

func (s *Config) WithEndpoint(v string) *Config

func (*Config) WithHost

func (s *Config) WithHost(v string) *Config

func (*Config) WithPort

func (s *Config) WithPort(v int) *Config

func (*Config) WithPprof

func (s *Config) WithPprof(v bool) *Config

func (*Config) WithPrefix

func (s *Config) WithPrefix(v string) *Config

type Handler

type Handler interface {
	Register(gin.IRouter)
}

type Info

type Info struct {
	Name    string
	Version string
	Commit  string
	BuildAt string
}

type Service

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

func New

func New(conf *Config, info *Info, fn func(gin.IRouter)) *Service

func (*Service) Build

func (s *Service) Build() *Service

func (*Service) Close

func (s *Service) Close() error

func (*Service) Engine

func (s *Service) Engine() *gin.Engine

func (*Service) Routes

func (s *Service) Routes() []gin.RouteInfo

func (*Service) Serve

func (s *Service) Serve() error

func (*Service) Server

func (s *Service) Server() *http.Server

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

Jump to

Keyboard shortcuts

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