cServer

package module
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouteNotFound = "/not-found"
)

Variables

This section is empty.

Functions

func DI added in v0.3.8

func DI(object, attr interface{})

func GetInstance

func GetInstance(index string) interface{}

func GetResourcePath added in v0.0.52

func GetResourcePath(relativeSubPath string) (absolute, relative string)

func Inject

func Inject(instance interface{})

func InjectConf added in v0.0.52

func InjectConf(conf interface{})

func InjectView added in v0.0.52

func InjectView(name string, fs *assetfs.AssetFS)

func Load

func Load()

func StartGRPC added in v0.0.52

func StartGRPC()

func StartHTTP

func StartHTTP()

Types

type A added in v0.3.8

type A struct {
	Name string
}

type ApplicationContainer

type ApplicationContainer struct {
	ExitChannel    chan os.Signal
	HttpServer     *http.Server
	HttpServerConf *ApplicationContainer_HttpServerConf
	Routes         []*ApplicationContainer_Route
	GrpcServerConf *ApplicationContainer_GrpcServerConf
}

func (ApplicationContainer) ListenExitChannel

func (app ApplicationContainer) ListenExitChannel()

type ApplicationContainer_GrpcServerConf added in v0.0.52

type ApplicationContainer_GrpcServerConf struct {
	Enable bool
	Host   string
	Port   int
}

type ApplicationContainer_HttpServerConf

type ApplicationContainer_HttpServerConf struct {
	Enable          bool
	Debug           bool
	Port            int
	ReadTimeout     int
	WriteTimeout    int
	ExitTimeout     int
	MaxHeaderBytes  int
	BasicAuthEnable bool
	BasicAuthUsers  map[string]string
	Cross           *ApplicationContainer_HttpServerConf_Cross
}

type ApplicationContainer_HttpServerConf_Cross added in v0.0.52

type ApplicationContainer_HttpServerConf_Cross struct {
	Enable           bool
	AllowOrigins     []string
	AllowMethods     []string
	AllowHeaders     []string
	AllowCredentials bool
	AllowWebSockets  bool
	MaxAge           int64
}

type ApplicationContainer_Route

type ApplicationContainer_Route struct {
	Grpc                      string                            `json:"grpc"`
	Path                      string                            `json:"path"`
	Method                    []string                          `json:"method"`
	File                      string                            `json:"file"`
	Dir                       string                            `json:"dir"`
	Type                      RouteType                         `json:"type"`
	View                      *assetfs.AssetFS                  `json:"-"`
	Handler                   gin.HandlerFunc                   `json:"-"`
	PrefixMiddlewares         []gin.HandlerFunc                 `json:"-"`
	SuffixMiddlewares         []gin.HandlerFunc                 `json:"-"`
	PrefixMiddlewareInstances []cMiddleware.MiddlewareInterface `json:"-"`
	SuffixMiddlewareInstances []cMiddleware.MiddlewareInterface `json:"-"`
}

func Routes added in v0.0.52

func Routes() []*ApplicationContainer_Route

type B added in v0.3.8

type B struct {
	AA *A `json:"aa"`
	BB *A
}

func (*B) Print added in v0.3.8

func (b *B) Print()

type GrpcServiceInterface added in v0.0.52

type GrpcServiceInterface interface {
	GrpcServiceDesc() *grpc.ServiceDesc
}

type RouteConf

type RouteConf struct {
	Grpc        string                 `json:"grpc"`
	Path        string                 `json:"path"`
	Method      []string               `json:"method"`
	File        string                 `json:"file"`
	Dir         string                 `json:"dir"`
	View        string                 `json:"view"`
	App         string                 `json:"app"`
	Controller  string                 `json:"controller"`
	Function    string                 `json:"function"`
	Middlewares *RouteConf_Middlewares `json:"middlewares"`
	Routes      []*RouteConf           `json:"routes"`
}

func GetRouteConf added in v0.0.52

func GetRouteConf() *RouteConf

func (*RouteConf) ConfigName

func (i *RouteConf) ConfigName() string

type RouteConf_Middleware

type RouteConf_Middleware struct {
	App  string `json:"app"`
	Name string `json:"name"`
}

type RouteConf_Middlewares added in v0.0.7

type RouteConf_Middlewares struct {
	Prefix []*RouteConf_Middleware `json:"prefix"`
	Suffix []*RouteConf_Middleware `json:"suffix"`
}

type RouteType added in v0.0.52

type RouteType uint8
const (
	RouteTypeNil RouteType = iota
	RouteTypeHandler
	RouteTypeFile
	RouteTypeDir
	RouteTypeView
)

type ServerConf

type ServerConf struct {
	ServerName string                 `json:"server_name"`
	HttpServer *ServerConf_HttpServer `json:"http_server"`
	GrpcServer *ServerConf_GrpcServer `json:"grpc_server"`
}

func GetServerConf added in v0.0.52

func GetServerConf() *ServerConf

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 服务
	Host   string `json:"host"`   // grpc 服务端 ip
	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"`     // 返回内容写入超时时间
	ExitTimeout     int                          `json:"exit_timeout"`      // 请求超时时间
	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 {
	Lock      *sync.Mutex
	Instances map[string]interface{}
}

func (*ServerContainer) Clear

func (i *ServerContainer) Clear()

func (*ServerContainer) Get

func (i *ServerContainer) Get(index string) interface{}

func (*ServerContainer) Remove

func (i *ServerContainer) Remove(instance interface{})

func (*ServerContainer) Save

func (i *ServerContainer) Save(instance interface{})

type ViewsContainer added in v0.0.52

type ViewsContainer struct {
	Lock  *sync.Mutex
	Views map[string]*assetfs.AssetFS
}

func (*ViewsContainer) Get added in v0.0.52

func (c *ViewsContainer) Get(name string) *assetfs.AssetFS

func (*ViewsContainer) Save added in v0.0.52

func (c *ViewsContainer) Save(name string, fs *assetfs.AssetFS)

Jump to

Keyboard shortcuts

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