application

package
v0.0.0-...-86e0aa6 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName = "applicattion_config"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	AppName        string `json:"name" yaml:"name" toml:"name" env:"APP_NAME"`
	AppDescription string `json:"description" yaml:"description" toml:"description" env:"APP_DESCRIPTION"`
	EncryptKey     string `json:"encrypt_key" yaml:"encrypt_key" toml:"encrypt_key" env:"APP_ENCRYPT_KEY"`

	HTTP *Http `json:"http" yaml:"http"  toml:"http"`
}

func App

func App() *Application

func (*Application) AllowOverwrite

func (u *Application) AllowOverwrite() bool

func (*Application) Close

func (u *Application) Close(ctx context.Context) error

func (*Application) Init

func (u *Application) Init() error

func (*Application) Name

func (u *Application) Name() string

func (*Application) Priority

func (u *Application) Priority() int

func (*Application) Version

func (u *Application) Version() string

type BuildConfig

type BuildConfig struct {
}

type Http

type Http struct {
	// 默认根据
	Enable *bool `json:"enable" yaml:"enable" toml:"enable" env:"HTTP_ENABLE"`
	// HTTP服务Host
	Host string `json:"size" yaml:"size" toml:"size" env:"HTTP_HOST"`
	// HTTP服务端口
	Port int `json:"port" yaml:"port" toml:"port" env:"HTTP_PORT"`

	// 使用的http框架, 启用后会自动从ioc中加载 该框架的hanlder
	WEB_FRAMEWORK WEB_FRAMEWORK `json:"web_framework" yaml:"web_framework" toml:"web_framework" env:"HTTP_WEB_FRAMEWORK"`

	// HTTP服务器参数
	ReadHeaderTimeoutSecond int `json:"read_header_timeout" yaml:"read_header_timeout" toml:"read_header_timeout" env:"HTTP_READ_HEADER_TIMEOUT"`
	// 读取HTTP整个请求时的参数
	ReadTimeoutSecond int `json:"read_timeout" yaml:"read_timeout" toml:"read_timeout" env:"HTTP_READ_TIMEOUT"`
	// 响应超时事件
	WriteTimeoutSecond int `json:"write_timeout" yaml:"write_timeout" toml:"write_timeout" env:"HTTP_WRITE_TIMEOUT"`
	// 启用了KeepAlive时 复用TCP链接的超时时间
	IdleTimeoutSecond int `json:"idle_timeout" yaml:"idle_timeout" toml:"idle_timeout" env:"HTTP_IDLE_TIMEOUT"`
	// header最大大小
	MaxHeaderSize string `json:"max_header_size" yaml:"max_header_size" toml:"max_header_size" env:"HTTP_MAX_HEADER_SIZE"`

	// SSL启用参数
	EnableSSL bool   `json:"enable_ssl" yaml:"enable_ssl" toml:"enable_ssl" env:"HTTP_ENABLE_SSL"`
	CertFile  string `json:"cert_file" yaml:"cert_file" toml:"cert_file" env:"HTTP_CERT_FILE"`
	KeyFile   string `json:"key_file" yaml:"key_file" toml:"key_file" env:"HTTP_KEY_FILE"`

	// 开启Trace
	EnableTrace bool `toml:"enable_trace" json:"enable_trace" yaml:"enable_trace"  env:"HTTP_ENABLE_TRACE"`
	// 开启HTTP健康检查
	EnableHealthCheck bool `toml:"enable_health_check" json:"enable_health_check" yaml:"enable_health_check"  env:"HTTP_ENABLE_HEALTH_CHECK"`
	// 开启跨越允许
	EnableCors bool `toml:"enable_cors" json:"enable_cors" yaml:"enable_cors"  env:"HTTP_ENABLE_CORS"`

	// 是否开启API Doc
	EnableApiDoc bool `json:"enable_api_doc" yaml:"enable_api_doc" toml:"enable_api_doc" env:"HTTP_ENABLE_API_DOC"`
	// Swagger API Doc URL路径
	ApiDocPath string `json:"api_doc_path" yaml:"api_doc_path" toml:"api_doc_path" env:"HTTP_API_DOC_PATH"`

	// 解析后的数据
	// maxHeaderBytes uint64
	// log               *zerolog.Logger
	// server            *http.Server
	// routerBuilders    map[WEB_FRAMEWORK]RouterBuilder `json:"-" yaml:"-" toml:"-" env:"-"`
	RouterBuildConfig *BuildConfig
}

func NewDefaultHttp

func NewDefaultHttp() *Http

func (*Http) Start

func (h *Http) Start(ctx context.Context)

Start 启动服务

type RouterBuilder

type RouterBuilder interface {
}

type WEB_FRAMEWORK

type WEB_FRAMEWORK string
const (
	WEB_FRAMEWORK_GO_RESTFUL WEB_FRAMEWORK = "go-restful"
	WEB_FRAMEWORK_GIN        WEB_FRAMEWORK = "gin"
)

Jump to

Keyboard shortcuts

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