server

package
v0.0.0-...-4f9d474 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RecommendedHomeDir 定义了所有 skeleton 服务配置文件的默认存放目录.
	RecommendedHomeDir = ".skt"

	// RecommendedEnvPrefix 定义了所有 skeleton 服务环境变量的前缀.
	RecommendedEnvPrefix = "SKT"
)

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(cfg string, defaultName string)

LoadConfig 读取配置文件和 ENV 变量.

func SetupSignalHandler

func SetupSignalHandler() <-chan struct{}

SetupSignalHandler 返回一个 stop 通道,应用程序在监听到该通道关闭后,执行资源清理.

Types

type CertKey

type CertKey struct {
	// CertFile 是一个包含 PEM 编码的证书的文件,可能还包含完整的证书链.
	CertFile string
	// KeyFile 是一个包含 CertFile 指定证书 PEM 编码私钥的文件.
	KeyFile string
}

CertKey 包含与证书相关的配置项.

type CompletedConfig

type CompletedConfig struct {
	*Config
}

CompletedConfig 是一个完整的 GenericAPIServer 配置.

func (*CompletedConfig) New

func (c *CompletedConfig) New() (*GenericAPIServer, error)

type Config

type Config struct {
	SecureServing   *SecureServingInfo
	InsecureServing *InsecureServingInfo
	Jwt             *JwtInfo
	Mode            string
	Middlewares     []string
	Healthz         bool
	EnableProfiling bool
	EnableMetrics   bool
}

Config 是一个通用 API 服务器的配置结构.

func NewConfig

func NewConfig() *Config

NewConfig 创建一个默认 Config.

func (*Config) Complete

func (c *Config) Complete() *CompletedConfig

Complete 基于 Config 补充完整的配置.

type GenericAPIServer

type GenericAPIServer struct {

	// SecureServingInfo 保存 HTTPS 服务配置
	SecureServingInfo *SecureServingInfo

	// InsecureServingInfo 保存 HTTP 服务配置
	InsecureServingInfo *InsecureServingInfo

	// ShutdownTimeout 表示优雅关闭的超时时间
	ShutdownTimeout time.Duration

	*gin.Engine
	// contains filtered or unexported fields
}

GenericAPIServer 包含一个 skeleton api 服务器的配置. type GenericAPIServer gin.Engine.

func (*GenericAPIServer) Run

func (s *GenericAPIServer) Run() error

func (*GenericAPIServer) Shutdown

func (s *GenericAPIServer) Shutdown()

Shutdown 优雅关闭 API 服务.

type InsecureServingInfo

type InsecureServingInfo struct {
	Address string
}

InsecureServingInfo 保存 HTTP 服务配置.

type JwtInfo

type JwtInfo struct {
	Realm      string
	Key        string
	Timeout    time.Duration
	MaxRefresh time.Duration
}

JwtInfo 定义用于创建 JWT 身份验证中间件的 JWT 字段.

type SecureServingInfo

type SecureServingInfo struct {
	BindAddress string
	BindPort    int
	CertKey     CertKey
}

SecureServingInfo 保存 HTTPS 服务配置.

func (*SecureServingInfo) Address

func (s *SecureServingInfo) Address() string

Address 将 IP 和 port 拼接为一个地址字符串,如:0.0.0.0:8443.

Jump to

Keyboard shortcuts

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