Documentation ¶
Index ¶
- Constants
- Variables
- func GetVersion() string
- func Inject(instance any)
- func Load()
- func TestHTTP(req *http.Request) *httptest.ResponseRecorder
- type ComponentsConf
- type GrpcServiceInterface
- type RouteConf
- type RouteConf_Middleware
- type RouteConf_Middlewares
- type RouteItem
- type RouteType
- type ServerComponent
- type ServerConf
- type ServerConf_GrpcServer
- type ServerConf_HttpServer
- type ServerConf_HttpServer_Cross
- type ServerContainer
- func (i *ServerContainer) DI()
- func (i *ServerContainer) Get(name string) any
- func (i *ServerContainer) GetView(prefix string) *assetfs.AssetFS
- func (i *ServerContainer) Is(instance any) bool
- func (i *ServerContainer) IsView(instance any) bool
- func (i *ServerContainer) ParseRoute(route *RouteConf, middlewares []gin.HandlerFunc, middlewareNames []string, ...)
- func (i *ServerContainer) Range(f func(instance any))
- func (i *ServerContainer) Remove(name string) bool
- func (i *ServerContainer) Routes() []*RouteItem
- func (i *ServerContainer) Save(instance any) bool
- func (i *ServerContainer) SaveView(instance *assetfs.AssetFS) bool
Constants ¶
View Source
const ComponentsConfigName = "ComponentsConf"
View Source
const RouteConfigName = "RouteConf"
View Source
const ServerConfigName = "ServerConf"
Variables ¶
View Source
var Component = &ServerComponent{}
Functions ¶
func GetVersion ¶ added in v0.4.13
func GetVersion() string
Types ¶
type ComponentsConf ¶ added in v0.3.15
type ComponentsConf struct {
Components []cComponents.ComponentInterface
}
func (*ComponentsConf) ConfigName ¶ added in v0.3.15
func (i *ComponentsConf) ConfigName() string
type GrpcServiceInterface ¶ added in v0.0.52
type GrpcServiceInterface interface {
GrpcServiceDesc() *grpc.ServiceDesc
}
type RouteConf ¶
type RouteConf struct { Type RouteType `json:"type"` Path string `json:"path"` Method []string `json:"method"` Target string `json:"target"` App string `json:"app"` Controller string `json:"controller"` Function string `json:"function"` Middlewares []*RouteConf_Middleware `json:"middlewares"` Routes []*RouteConf `json:"routes"` }
func (*RouteConf) ConfigName ¶
type RouteConf_Middleware ¶
type RouteConf_Middlewares ¶ added in v0.0.7
type RouteConf_Middlewares struct { Prefix []*RouteConf_Middleware `json:"prefix"` Suffix []*RouteConf_Middleware `json:"suffix"` }
type RouteItem ¶ added in v0.4.0
type RouteItem struct { Type RouteType `json:"type"` Path string `json:"path"` Target string `json:"target"` Method []string `json:"method"` Handler gin.HandlerFunc `json:"-"` // Prefix []gin.HandlerFunc `json:"-"` // Suffix []gin.HandlerFunc `json:"-"` Middlewares []gin.HandlerFunc `json:"-"` MiddlewareNames []string `json:"middlewares"` }
type ServerComponent ¶ added in v0.4.0
type ServerComponent struct{}
func (*ServerComponent) Inject ¶ added in v0.4.0
func (i *ServerComponent) Inject(instance any) bool
func (*ServerComponent) InjectConf ¶ added in v0.4.0
func (i *ServerComponent) InjectConf(config cComponents.ConfigInterface) bool
func (*ServerComponent) Listen ¶ added in v0.4.0
func (i *ServerComponent) Listen() []*cComponents.ConfigListener
func (*ServerComponent) Load ¶ added in v0.4.0
func (i *ServerComponent) Load()
type ServerConf ¶
type ServerConf struct { ServerName string `json:"server_name"` HttpServer *ServerConf_HttpServer `json:"http_server"` GrpcServer *ServerConf_GrpcServer `json:"grpc_server"` }
func (*ServerConf) ConfigName ¶
func (i *ServerConf) ConfigName() string
type ServerConf_GrpcServer ¶ added in v0.0.52
type ServerConf_HttpServer ¶
type ServerConf_HttpServer struct { Enable bool `json:"enable"` // 是否启用 http 服务 Debug bool `json:"debug"` // 是否启用 pprof 工具 Port int `json:"port"` // http 端口号 ReadTimeout int `json:"read_timeout"` // 请求内容读取超时时间 WriteTimeout int `json:"write_timeout"` // 返回内容写入超时时间 IdleTimeout int `json:"idle_timeout"` // 在启用 keep-alive 的情况下,等待下一个请求的最大空闲时间。如果为零,则使用 ReadTimeout 的值 MaxHeaderBytes int `json:"max_header_bytes"` // 请求头大小 BasicAuthEnable bool `json:"basic_auth_enable"` // 是佛开启基础权限校验 BasicAuthUsers map[string]string `json:"basic_auth_users"` // 基础权限账号密码 Cross *ServerConf_HttpServer_Cross `json:"cross"` // 跨域设置 }
type ServerConf_HttpServer_Cross ¶ added in v0.0.52
type ServerConf_HttpServer_Cross struct { Enable bool `json:"enable"` AllowOrigins []string `json:"allow_origins"` AllowMethods []string `json:"allow_methods"` AllowHeaders []string `json:"allow_headers"` AllowCredentials bool `json:"allow_credentials"` AllowWebSockets bool `json:"allow_websockets"` MaxAge int64 `json:"max_age"` }
type ServerContainer ¶
type ServerContainer struct {
// contains filtered or unexported fields
}
func (*ServerContainer) DI ¶ added in v0.3.11
func (i *ServerContainer) DI()
func (*ServerContainer) Get ¶
func (i *ServerContainer) Get(name string) any
func (*ServerContainer) GetView ¶ added in v0.4.0
func (i *ServerContainer) GetView(prefix string) *assetfs.AssetFS
func (*ServerContainer) Is ¶ added in v0.4.0
func (i *ServerContainer) Is(instance any) bool
func (*ServerContainer) IsView ¶ added in v0.4.0
func (i *ServerContainer) IsView(instance any) bool
func (*ServerContainer) ParseRoute ¶ added in v0.4.0
func (i *ServerContainer) ParseRoute(route *RouteConf, middlewares []gin.HandlerFunc, middlewareNames []string, uri string)
func (*ServerContainer) Range ¶ added in v0.3.15
func (i *ServerContainer) Range(f func(instance any))
func (*ServerContainer) Remove ¶
func (i *ServerContainer) Remove(name string) bool
func (*ServerContainer) Routes ¶ added in v0.4.0
func (i *ServerContainer) Routes() []*RouteItem
func (*ServerContainer) Save ¶
func (i *ServerContainer) Save(instance any) bool
Click to show internal directories.
Click to hide internal directories.