cServer

package module
v0.4.20 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

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

func Initialize added in v0.4.17

func Initialize()

func Inject

func Inject(instance any)

func Load

func Load()

func TestHTTP added in v0.4.10

func TestHTTP(req *http.Request) *httptest.ResponseRecorder

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

func (i *RouteConf) ConfigName() string

type RouteConf_Middleware

type RouteConf_Middleware struct {
	App    string         `json:"app"`
	Name   string         `json:"name"`
	Params map[string]any `json:"params"`
}

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"`
}

func Routes added in v0.0.52

func Routes() []*RouteItem

type RouteType added in v0.0.52

type RouteType int
const (
	RouteTypeNil RouteType = iota
	RouteTypeApi
	RouteTypeFile
	RouteTypeDir
	RouteTypeView
	RouteTypeGrpc
	RouteTypeGroup
)

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 (*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_GrpcServer struct {
	Enable bool `json:"enable"` // 是否启用 grpc 服务
	Port   int  `json:"port"`   // grpc 服务端 端口
}

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

func (*ServerContainer) SaveView added in v0.4.0

func (i *ServerContainer) SaveView(instance *assetfs.AssetFS) bool

Jump to

Keyboard shortcuts

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