server

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package server 定义了所有平台通用的通用 apiserver

Index

Constants

View Source
const (
	// RecommendedHomeDir 定义了所有服务配置的默认目录
	RecommendedHomeDir = ".iam-apiserver"

	// RecommendedEnvPrefix 定义了所有服务的 ENV 前缀
	RecommendedEnvPrefix = "IAM_APISERVER"
)

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(cfg string, defaultName string)

LoadConfig 读取配置文件和环境变量

Types

type CertKey

type CertKey struct {
	// CertFile 包含 PEM 编码的证书,可能包含完整的证书链
	CertFile string
	// KeyFile 包含 PEM 编码的证书的私钥
	KeyFile string
}

CertKey contains configuration items related to certificate. 包含与证书相关的配置项

type CompletedConfig

type CompletedConfig struct {
	*Config
}

CompletedConfig 是 GenericAPIServer 的完成配置

func (CompletedConfig) New

New 从给定的配置创建一个新的 GenericAPIServer 实例

type Config

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

Config 是用于配置 GenericAPIServer 的结构体 其成员按重要性排序

func NewConfig

func NewConfig() *Config

NewConfig 返回一个包含默认值的 Config 结构体

func (*Config) Complete

func (c *Config) Complete() CompletedConfig

Complete 填充任何未设置的字段,这些字段是必需的,并且可以从其他字段派生出来 如果需要 `ApplyOptions`,请先执行该操作。它正在修改接收者。

type GenericAPIServer

type GenericAPIServer struct {
	SecureServingInfo   *SecureServingInfo
	InsecureServingInfo *InsecureServingInfo
	ShutdownTimeout     time.Duration
	*gin.Engine
	// contains filtered or unexported fields
}

GenericAPIServer 定义通用 API 服务器

func (*GenericAPIServer) Close

func (s *GenericAPIServer) Close()

Close 关闭 HTTP 服务器

func (*GenericAPIServer) InstallAPIs

func (s *GenericAPIServer) InstallAPIs()

InstallAPIs 安装通用 API

func (*GenericAPIServer) InstallMiddlewares

func (s *GenericAPIServer) InstallMiddlewares()

InstallMiddlewares 安装中间件

func (*GenericAPIServer) Run

func (s *GenericAPIServer) Run() error

Run 启动 HTTP 服务器

func (*GenericAPIServer) Setup

func (s *GenericAPIServer) Setup()

Setup 设置通用 API 服务器

type InsecureServingInfo

type InsecureServingInfo struct {
	Address string
}

InsecureServingInfo 包含不安全 HTTP 服务器的配置信息

type JwtInfo

type JwtInfo struct {
	// Realm 默认值为 "iam jwt"
	Realm string
	// Key 默认值为空
	Key string
	// Timeout 默认值为一小时
	Timeout time.Duration
	// MaxRefresh 默认值为零
	MaxRefresh time.Duration
}

JwtInfo 定义了用于创建 JWT 认证中间件的 JWT 字段

type SecureServingInfo

type SecureServingInfo struct {
	// BindAddress 绑定地址
	BindAddress string
	// BindPort 绑定端口
	BindPort int
	// CertKey 包含证书和私钥的配置
	CertKey CertKey
}

包含 TLS 服务器的配置信息

func (*SecureServingInfo) Address

func (s *SecureServingInfo) Address() string

Address 将主机 IP 地址和主机端口号连接成一个地址字符串,例如:0.0.0.0:8443

Jump to

Keyboard shortcuts

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