Documentation
¶
Index ¶
- Constants
- func StatusText(code int) string
- type Context
- type CorsOptions
- type Handler
- type Option
- func WithAddr(addr string) Option
- func WithCorsOptions(corsOpts CorsOptions) Option
- func WithCredentials(certFile, keyFile string) Option
- func WithMiddlewares(middlewares ...any) Option
- func WithName(name string) Option
- func WithRegistry(r gregistry.Registry) Option
- func WithSwagOptions(swagOpts SwagOptions) Option
- func WithTransporter(transporter gtransport.Transporter) Option
- type Proxy
- type Resp
- type Router
- type Server
- type SwagOptions
Constants ¶
View Source
const ( StatusContinue = http.StatusContinue // RFC 9110, 15.2.1 StatusSwitchingProtocols = http.StatusSwitchingProtocols // RFC 9110, 15.2.2 StatusProcessing = http.StatusProcessing // RFC 2518, 10.1 StatusEarlyHints = http.StatusEarlyHints // RFC 8297 StatusOK = http.StatusOK // RFC 9110, 15.3.1 StatusCreated = http.StatusCreated // RFC 9110, 15.3.2 StatusAccepted = http.StatusAccepted // RFC 9110, 15.3.3 StatusNonAuthoritativeInfo = http.StatusNonAuthoritativeInfo // RFC 9110, 15.3.4 StatusNoContent = http.StatusNoContent // RFC 9110, 15.3.5 StatusResetContent = http.StatusResetContent // RFC 9110, 15.3.6 StatusPartialContent = http.StatusPartialContent // RFC 9110, 15.3.7 StatusMultiStatus = http.StatusMultiStatus // RFC 4918, 11.1 StatusAlreadyReported = http.StatusAlreadyReported // RFC 5842, 7.1 StatusIMUsed = http.StatusIMUsed // RFC 3229, 10.4.1 StatusMultipleChoices = http.StatusMultipleChoices // RFC 9110, 15.4.1 StatusMovedPermanently = http.StatusMovedPermanently // RFC 9110, 15.4.2 StatusFound = http.StatusFound // RFC 9110, 15.4.3 StatusSeeOther = http.StatusSeeOther // RFC 9110, 15.4.4 StatusNotModified = http.StatusNotModified // RFC 9110, 15.4.5 StatusUseProxy = http.StatusUseProxy // RFC 9110, 15.4.6 StatusTemporaryRedirect = http.StatusTemporaryRedirect // RFC 9110, 15.4.8 StatusPermanentRedirect = http.StatusPermanentRedirect // RFC 9110, 15.4.9 StatusBadRequest = http.StatusBadRequest // RFC 9110, 15.5.1 StatusPaymentRequired = http.StatusPaymentRequired // RFC 9110, 15.5.3 StatusForbidden = http.StatusForbidden // RFC 9110, 15.5.4 StatusNotFound = http.StatusNotFound // RFC 9110, 15.5.5 StatusMethodNotAllowed = http.StatusMethodNotAllowed // RFC 9110, 15.5.6 StatusNotAcceptable = http.StatusNotAcceptable // RFC 9110, 15.5.7 StatusProxyAuthRequired = http.StatusProxyAuthRequired // RFC 9110, 15.5.8 StatusRequestTimeout = http.StatusRequestTimeout // RFC 9110, 15.5.9 StatusConflict = http.StatusConflict // RFC 9110, 15.5.10 StatusGone = http.StatusGone // RFC 9110, 15.5.11 StatusLengthRequired = http.StatusLengthRequired // RFC 9110, 15.5.12 StatusPreconditionFailed = http.StatusPreconditionFailed // RFC 9110, 15.5.13 StatusRequestEntityTooLarge = http.StatusRequestEntityTooLarge // RFC 9110, 15.5.14 StatusRequestURITooLong = http.StatusRequestURITooLong // RFC 9110, 15.5.15 StatusUnsupportedMediaType = http.StatusUnsupportedMediaType // RFC 9110, 15.5.16 StatusRequestedRangeNotSatisfiable = http.StatusRequestedRangeNotSatisfiable // RFC 9110, 15.5.17 StatusExpectationFailed = http.StatusExpectationFailed // RFC 9110, 15.5.18 StatusTeapot = http.StatusTeapot // RFC 9110, 15.5.19 (Unused) StatusMisdirectedRequest = http.StatusMisdirectedRequest // RFC 9110, 15.5.20 StatusUnprocessableEntity = http.StatusUnprocessableEntity // RFC 9110, 15.5.21 StatusLocked = http.StatusLocked // RFC 4918, 11.3 StatusFailedDependency = http.StatusFailedDependency // RFC 4918, 11.4 StatusTooEarly = http.StatusTooEarly // RFC 8470, 5.2. StatusUpgradeRequired = http.StatusUpgradeRequired // RFC 9110, 15.5.22 StatusPreconditionRequired = http.StatusPreconditionRequired // RFC 6585, 3 StatusTooManyRequests = http.StatusTooManyRequests // RFC 6585, 4 StatusRequestHeaderFieldsTooLarge = http.StatusRequestHeaderFieldsTooLarge // RFC 6585, 5 StatusInternalServerError = http.StatusInternalServerError // RFC 9110, 15.6.1 StatusNotImplemented = http.StatusNotImplemented // RFC 9110, 15.6.2 StatusBadGateway = http.StatusBadGateway // RFC 9110, 15.6.3 StatusGatewayTimeout = http.StatusGatewayTimeout // RFC 9110, 15.6.5 StatusHTTPVersionNotSupported = http.StatusHTTPVersionNotSupported // RFC 9110, 15.6.6 StatusVariantAlsoNegotiates = http.StatusVariantAlsoNegotiates // RFC 2295, 8.1 StatusInsufficientStorage = http.StatusInsufficientStorage // RFC 4918, 11.5 StatusLoopDetected = http.StatusLoopDetected // RFC 5842, 7.2 StatusNotExtended = http.StatusNotExtended // RFC 2774, 7 StatusNetworkAuthenticationRequired = http.StatusNetworkAuthenticationRequired // RFC 6585, 6 )
Variables ¶
This section is empty.
Functions ¶
func StatusText ¶
Types ¶
type CorsOptions ¶
type CorsOptions struct { Enable bool `json:"enable"` // 是否启用 AllowOrigins []string `json:"allowOrigins"` // 允许跨域的请求源。默认为[],即为允许所有请求源 AllowMethods []string `json:"allowMethods"` // 允许跨域的请求方法。默认为["GET", "POST", "HEAD", "PUT", "DELETE", "PATCH"] AllowHeaders []string `json:"allowHeaders"` // 允许跨域的请求头部。默认为[],即为允许所有请求头部 AllowCredentials bool `json:"allowCredentials"` // 当允许所有源时,根据CORS规范不允许携带凭据。默认为false ExposeHeaders []string `json:"exposeHeaders"` // 允许暴露给客户端的头部。默认为[],即为允许暴露所有头部 MaxAge int `json:"maxAge"` // 浏览器缓存预检请求结果的时间。默认为0 AllowPrivateNetwork bool `json:"allowPrivateNetwork"` // 是否允许来自私有网络的请求。设置为true时,响应头Access-Control-Allow-Private-Network会被设置为true。默认为false }
type Option ¶
type Option func(o *options)
func WithCredentials ¶
WithCredentials 设置证书和秘钥
func WithSwagOptions ¶
func WithSwagOptions(swagOpts SwagOptions) Option
WithSwagOptions 设置swagger配置
func WithTransporter ¶
func WithTransporter(transporter gtransport.Transporter) Option
WithTransporter 设置消息传输器
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
func (*Proxy) NewMeshClient ¶
func (p *Proxy) NewMeshClient(target string) (gtransport.Client, error)
NewMeshClient 新建微服务客户端 target参数可分为三种模式: 服务直连模式: direct://127.0.0.1:8011 服务直连模式: direct://711baf8d-8a06-11ef-b7df-f4f19e1f0070 服务发现模式: discovery://service_name
type Router ¶
type Router interface { // Get 添加GET请求处理器 Get(path string, handler any, middlewares ...any) Router // Post 添加POST请求处理器 Post(path string, handler any, middlewares ...any) Router // Head 添加HEAD请求处理器 Head(path string, handler any, middlewares ...any) Router // Put 添加PUT请求处理器 Put(path string, handler any, middlewares ...any) Router // Delete 添加DELETE请求处理器 Delete(path string, handler any, middlewares ...any) Router // Connect 添加CONNECT请求处理器 Connect(path string, handler any, middlewares ...any) Router // Options 添加OPTIONS请求处理器 Options(path string, handler any, middlewares ...any) Router // Trace 添加TRACE请求处理器 Trace(path string, handler any, middlewares ...any) Router // Patch 添加PATCH请求处理器 Patch(path string, handler any, middlewares ...any) Router // Add 添加路由处理器 Add(methods []string, path string, handler any, middlewares ...any) Router // Group 路由组 Group(prefix string, handlers ...any) Router // AddHandlers 批量添加 AddHandlers(mng ghandler.Manager, middlewares ...any) Router }
Click to show internal directories.
Click to hide internal directories.