http

package
v0.13.6-0...-d3ad96a Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRootPrivileges = errors.New("You must have root user privileges. Possibly using 'sudo' command should help")
View Source
var ErrUnsupportedSystem = errors.New("Unsupported system")

Functions

func CheckFixedSecret

func CheckFixedSecret(cnf conf.IServerConf) (enable bool, err error)

CheckFixedSecret 设置FixedSecret

func CheckRemoteAuth

func CheckRemoteAuth(cnf conf.IServerConf) (enable bool, err error)

CheckRemoteAuth 检查是否设置remote-auth

func SetAjaxRequest

func SetAjaxRequest(set IAjaxRequest, cnf conf.IServerConf) (enable bool, err error)

SetAjaxRequest 设置ajax

func SetCircuitBreaker

func SetCircuitBreaker(set ISetCircuitBreaker, cnf conf.IServerConf) (enable bool, err error)

SetCircuitBreaker 设置熔断配置

func SetHeaders

func SetHeaders(set ISetHeaderHandler, cnf conf.IServerConf) (enable bool, err error)

SetHeaders 设置header

func SetHosts

func SetHosts(set ISetHosts, cnf conf.IServerConf) (enable bool, err error)

SetHosts 设置hosts

func SetHttpRouters

func SetHttpRouters(engine servers.IRegistryEngine, set ISetRouterHandler, cnf conf.IServerConf) (enable bool, err error)

SetHttpRouters 设置路由

func SetJWT

func SetJWT(set ISetJwtAuth, cnf conf.IServerConf) (enable bool, err error)

SetJWT 设置jwt

func SetMetric

func SetMetric(set ISetMetric, cnf conf.IServerConf) (enable bool, err error)

SetMetric 设置metric

func SetResponse

func SetResponse(set ISetResponse, cnf conf.IServerConf) (enable bool, err error)

SetResponse 设置response配置串

func SetStatic

func SetStatic(set ISetStatic, cnf conf.IServerConf) (enable bool, err error)

SetStatic 设置static

func SetView

func SetView(set ISetView, cnf conf.IServerConf) (enable bool, err error)

SetView 设置view

Types

type ApiResponsiveServer

type ApiResponsiveServer struct {
	*logger.Logger
	// contains filtered or unexported fields
}

ApiResponsiveServer api 响应式服务器

func NewApiResponsiveServer

func NewApiResponsiveServer(registryAddr string, cnf conf.IServerConf, logger *logger.Logger) (h *ApiResponsiveServer, err error)

NewApiResponsiveServer 创建API服务器

func (*ApiResponsiveServer) GetAddress

func (w *ApiResponsiveServer) GetAddress() string

GetAddress 获取服务器地址

func (*ApiResponsiveServer) GetServices

func (w *ApiResponsiveServer) GetServices() map[string][]string

GetServices 获取服务列表

func (*ApiResponsiveServer) GetStatus

func (w *ApiResponsiveServer) GetStatus() string

GetStatus 获取当前服务器状态

func (*ApiResponsiveServer) NeedRestart

func (w *ApiResponsiveServer) NeedRestart(cnf conf.IServerConf) (bool, error)

NeedRestart 检查配置判断是否需要重启服务器

func (*ApiResponsiveServer) Notify

func (w *ApiResponsiveServer) Notify(conf conf.IServerConf) error

Notify 服务器配置变更通知

func (*ApiResponsiveServer) Restart

func (w *ApiResponsiveServer) Restart(cnf conf.IServerConf) (err error)

Restart 重启服务器

func (*ApiResponsiveServer) Restarted

func (w *ApiResponsiveServer) Restarted() bool

Restarted 服务器是否已重启

func (*ApiResponsiveServer) SetConf

func (w *ApiResponsiveServer) SetConf(restart bool, cnf conf.IServerConf) (err error)

SetConf 设置配置参数

func (*ApiResponsiveServer) Shutdown

func (w *ApiResponsiveServer) Shutdown()

Shutdown 关闭服务器

func (*ApiResponsiveServer) Start

func (w *ApiResponsiveServer) Start() (err error)

Start 启用服务

type ApiServer

type ApiServer struct {
	// contains filtered or unexported fields
}

ApiServer api服务器

func NewApiServer

func NewApiServer(name string, addr string, routers []*conf.Router, opts ...Option) (t *ApiServer, err error)

NewApiServer 创建api服务器

func (*ApiServer) CloseCircuitBreaker

func (s *ApiServer) CloseCircuitBreaker() error

CloseCircuitBreaker 关闭熔断配置

func (*ApiServer) GetAddress

func (s *ApiServer) GetAddress(h ...string) string

GetAddress 获取当前服务地址

func (*ApiServer) GetStatus

func (s *ApiServer) GetStatus() string

GetStatus 获取当前服务器状态

func (*ApiServer) Run

func (s *ApiServer) Run() error

Run the http server

func (*ApiServer) SetAjaxRequest

func (s *ApiServer) SetAjaxRequest(allow bool) error

SetAjaxRequest 只允许ajax请求

func (*ApiServer) SetCircuitBreaker

func (s *ApiServer) SetCircuitBreaker(c *conf.CircuitBreaker) error

SetCircuitBreaker 设置熔断配置

func (*ApiServer) SetHeader

func (s *ApiServer) SetHeader(headers conf.Headers) error

SetHeader 设置http头

func (*ApiServer) SetHosts

func (s *ApiServer) SetHosts(hosts conf.Hosts) error

SetHosts 设置组件的host name

func (*ApiServer) SetJWT

func (s *ApiServer) SetJWT(auth *conf.JWTAuth) error

SetJWT Server

func (*ApiServer) SetMetric

func (s *ApiServer) SetMetric(metric *conf.Metric) error

SetMetric 重置metric

func (*ApiServer) SetResponse

func (s *ApiServer) SetResponse(r *conf.Response) error

SetResponse 设置response配置

func (*ApiServer) SetRouters

func (s *ApiServer) SetRouters(routers []*conf.Router) (err error)

SetRouters 设置路由配置

func (*ApiServer) SetStatic

func (s *ApiServer) SetStatic(static *conf.Static) error

SetStatic 设置静态文件路由

func (*ApiServer) SetTrace

func (s *ApiServer) SetTrace(b bool)

SetTrace 显示跟踪信息

func (*ApiServer) Shutdown

func (s *ApiServer) Shutdown(timeout time.Duration)

Shutdown 关闭服务器

func (*ApiServer) StopMetric

func (s *ApiServer) StopMetric() error

StopMetric stop metric

type Handler

type Handler interface {
	Handle(*gin.Context)
}

type IAjaxRequest

type IAjaxRequest interface {
	SetAjaxRequest(bool) error
}

IAjaxRequest 设置ajax

type IServer

type IServer interface {
	Run() error
	Shutdown(timeout time.Duration)
	GetStatus() string
	GetAddress(h ...string) string
	CloseCircuitBreaker() error
	SetCircuitBreaker(*conf.CircuitBreaker) error

	SetResponse(*conf.Response) error
	SetRouters(routers []*conf.Router) (err error)
	SetJWT(auth *conf.JWTAuth) error
	SetAjaxRequest(allow bool) error
	SetHosts(conf.Hosts) error
	SetStatic(*conf.Static) error
	SetMetric(*conf.Metric) error
	SetHeader(conf.Headers) error
	StopMetric() error
}

type ISetCircuitBreaker

type ISetCircuitBreaker interface {
	CloseCircuitBreaker() error
	SetCircuitBreaker(*conf.CircuitBreaker) error
}

ISetCircuitBreaker 设置CircuitBreaker

type ISetHeaderHandler

type ISetHeaderHandler interface {
	SetHeader(conf.Headers) error
}

ISetHeaderHandler 设置header

type ISetHosts

type ISetHosts interface {
	SetHosts(conf.Hosts) error
}

ISetHosts 设置hosts

type ISetJwtAuth

type ISetJwtAuth interface {
	SetJWT(*conf.JWTAuth) error
}

ISetJwtAuth 设置jwt

type ISetMetric

type ISetMetric interface {
	SetMetric(*conf.Metric) error
}

type ISetResponse

type ISetResponse interface {
	SetResponse(*conf.Response) error
}

ISetResponse 设置response配置串

type ISetRouterHandler

type ISetRouterHandler interface {
	SetRouters([]*conf.Router) error
}

ISetRouterHandler 设置路由列表

type ISetStatic

type ISetStatic interface {
	SetStatic(static *conf.Static) error
}

type ISetView

type ISetView interface {
	SetView(*conf.View) error
}

ISetView 设置view

type Option

type Option func(*option)

Option 配置选项

func WithLogger

func WithLogger(logger *logger.Logger) Option

WithLogger 设置日志记录组件

func WithMetric

func WithMetric(host string, dataBase string, userName string, password string, cron string) Option

WithMetric 设置基于influxdb的系统监控组件

func WithName

func WithName(platName string, systemName string, clusterName string, serverType string) Option

func WithShowTrace

func WithShowTrace(b bool) Option

WithShowTrace 显示跟踪信息

func WithTLS

func WithTLS(tls []string) Option

WithTLS 设置TLS证书(pem,key)

func WithTimeout

func WithTimeout(readTimeout int, writeTimeout int, readHeaderTimeout int) Option

WithTimeout 设置服务器超时时长

type Routers

type Routers struct {
	// contains filtered or unexported fields
}

func GetRouters

func GetRouters() *Routers

func (*Routers) Get

func (r *Routers) Get() []*conf.Router

func (*Routers) Route

func (r *Routers) Route(method string, name string, f interface{})

type WebResponsiveServer

type WebResponsiveServer struct {
	*ApiResponsiveServer
	// contains filtered or unexported fields
}

WebResponsiveServer web 响应式服务器

func NewWebResponsiveServer

func NewWebResponsiveServer(registryAddr string, cnf conf.IServerConf, logger *logger.Logger) (h *WebResponsiveServer, err error)

NewWebResponsiveServer 构建基于注册中心的响应式web服务器

func (*WebResponsiveServer) NeedRestart

func (w *WebResponsiveServer) NeedRestart(cnf conf.IServerConf) (bool, error)

NeedRestart 检查配置判断是否需要重启服务器

func (*WebResponsiveServer) Notify

func (w *WebResponsiveServer) Notify(conf conf.IServerConf) error

Notify 服务器配置变更通知

func (*WebResponsiveServer) Restart

func (w *WebResponsiveServer) Restart(cnf conf.IServerConf) (err error)

Restart 重启服务器

func (*WebResponsiveServer) SetConf

func (w *WebResponsiveServer) SetConf(restart bool, conf conf.IServerConf) (err error)

SetConf 设置配置参数

type WebServer

type WebServer struct {
	// contains filtered or unexported fields
}

WebServer web服务器

func NewWebServer

func NewWebServer(name string, addr string, routers []*conf.Router, opts ...Option) (t *WebServer, err error)

NewWebServer 创建web服务器

func (*WebServer) CloseCircuitBreaker

func (s *WebServer) CloseCircuitBreaker() error

CloseCircuitBreaker 关闭熔断配置

func (*WebServer) GetAddress

func (s *WebServer) GetAddress(h ...string) string

GetAddress 获取当前服务地址

func (*WebServer) GetStatus

func (s *WebServer) GetStatus() string

GetStatus 获取当前服务器状态

func (*WebServer) Run

func (s *WebServer) Run() error

Run the http server

func (*WebServer) RunTLS

func (s *WebServer) RunTLS(certFile, keyFile string) error

RunTLS RunTLS server

func (*WebServer) SetAjaxRequest

func (s *WebServer) SetAjaxRequest(allow bool) error

SetAjaxRequest 只允许ajax请求

func (*WebServer) SetCircuitBreaker

func (s *WebServer) SetCircuitBreaker(c *conf.CircuitBreaker) error

SetCircuitBreaker 设置熔断配置

func (*WebServer) SetHeader

func (s *WebServer) SetHeader(headers conf.Headers) error

SetHeader 设置http头

func (*WebServer) SetHosts

func (s *WebServer) SetHosts(hosts conf.Hosts) error

SetHosts 设置组件的host name

func (*WebServer) SetJWT

func (s *WebServer) SetJWT(auth *conf.JWTAuth) error

SetJWT Server

func (*WebServer) SetMetric

func (s *WebServer) SetMetric(metric *conf.Metric) error

SetMetric 重置metric

func (*WebServer) SetResponse

func (s *WebServer) SetResponse(r *conf.Response) error

SetResponse 设置response配置

func (*WebServer) SetRouters

func (s *WebServer) SetRouters(routers []*conf.Router) (err error)

SetRouters 设置路由配置

func (*WebServer) SetStatic

func (s *WebServer) SetStatic(static *conf.Static) error

SetStatic 设置静态文件路由

func (*WebServer) SetTrace

func (s *WebServer) SetTrace(b bool)

SetTrace 显示跟踪信息

func (*WebServer) SetView

func (s *WebServer) SetView(view *conf.View) (err error)

SetView 设置view参数

func (*WebServer) Shutdown

func (s *WebServer) Shutdown(timeout time.Duration)

Shutdown 关闭服务器

func (*WebServer) StopMetric

func (s *WebServer) StopMetric() error

StopMetric stop metric

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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