Documentation
¶
Index ¶
- Constants
- func BindJSON[T any](c *Context) (t *T, err error)
- func Error(msg string, fields ...zap.Field)
- func Info(msg string, fields ...zap.Field)
- func InitZap()
- func NewLogger() *zap.Logger
- func ParseFromRequest(req *http.Request, publicKeyPath string) (uniqueUser, issuer, signature string, err error)
- func SetAuthToken(uniqueUser, issuer, privateKeyPath string, expire time.Duration) (tokenString string, err error)
- func Warn(msg string, fields ...zap.Field)
- type Context
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Err() error
- func (c *Context) Get(key string) (value any, exists bool)
- func (c *Context) JSON(status int, data any) error
- func (c *Context) Param(key string) string
- func (c *Context) Set(key string, value any)
- func (c *Context) ShouldBindJSON(obj any) error
- func (c *Context) ShouldBindWith(obj any, b binding.Binding) error
- func (c *Context) Value(key any) any
- type ErrorHandler
- type ErrorHandlerFunc
- type H
- type Handler
- type HandlerFunc
- type LogErrorHandler
- type Router
- func (r *Router) Get(route string, handler HandlerFunc)
- func (r *Router) Group(prefix string) *Router
- func (r *Router) Method(method, route string, handler HandlerFunc)
- func (r *Router) Post(route string, handler HandlerFunc)
- func (r *Router) Serve(addr string, server ...*http.Server) error
- func (r *Router) Use(middlewares ...func(HandlerFunc) HandlerFunc)
- type Server
- type ServerBase
- type ServerFinalizerFunc
- type ServerOption
- type Service
Constants ¶
View Source
const ContextKey = "_go-water/context-key"
Variables ¶
This section is empty.
Functions ¶
func ParseFromRequest ¶ added in v0.2.6
func ParseFromRequest(req *http.Request, publicKeyPath string) (uniqueUser, issuer, signature string, err error)
ParseFromRequest 兼容 http,ws
func SetAuthToken ¶ added in v0.2.0
Types ¶
type Context ¶ added in v0.5.0
type Context struct { Request *http.Request Writer http.ResponseWriter Keys map[string]any // contains filtered or unexported fields }
func (*Context) Deadline ¶ added in v0.5.0
Deadline returns that there is no deadline (ok==false) when c.Request has no Context.
func (*Context) Done ¶ added in v0.5.0
func (c *Context) Done() <-chan struct{}
Done returns nil (chan which will wait forever) when c.Request has no Context.
func (*Context) ShouldBindJSON ¶ added in v0.5.0
func (*Context) ShouldBindWith ¶ added in v0.5.0
type ErrorHandler ¶
type ErrorHandlerFunc ¶
type Handler ¶
type Handler interface { ServerWater(ctx context.Context, req any) (any, error) GetLogger() *zap.Logger }
func NewHandler ¶
func NewHandler(srv Service, options ...ServerOption) Handler
type HandlerFunc ¶ added in v0.5.0
type HandlerFunc func(*Context)
func (HandlerFunc) ServeHTTP ¶ added in v0.5.0
func (handle HandlerFunc) ServeHTTP(w http.ResponseWriter, req *http.Request)
type LogErrorHandler ¶
type LogErrorHandler struct {
// contains filtered or unexported fields
}
func NewLogErrorHandler ¶
func NewLogErrorHandler(l *zap.Logger, n string) *LogErrorHandler
type Router ¶ added in v0.5.0
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Get ¶ added in v0.5.0
func (r *Router) Get(route string, handler HandlerFunc)
func (*Router) Method ¶ added in v0.5.0
func (r *Router) Method(method, route string, handler HandlerFunc)
func (*Router) Post ¶ added in v0.5.0
func (r *Router) Post(route string, handler HandlerFunc)
func (*Router) Use ¶ added in v0.5.0
func (r *Router) Use(middlewares ...func(HandlerFunc) HandlerFunc)
type ServerBase ¶ added in v0.0.12
type ServerBase struct {
// contains filtered or unexported fields
}
func (*ServerBase) GetLogger ¶ added in v0.0.18
func (s *ServerBase) GetLogger() *zap.Logger
func (*ServerBase) Name ¶ added in v0.0.12
func (s *ServerBase) Name(srv Service) string
func (*ServerBase) SetLogger ¶ added in v0.0.19
func (s *ServerBase) SetLogger(l *zap.Logger)
type ServerFinalizerFunc ¶
type ServerOption ¶
type ServerOption func(*Server)
func ServerBreaker ¶ added in v0.3.3
func ServerBreaker(breaker *gobreaker.CircuitBreaker) ServerOption
func ServerErrorHandler ¶ added in v0.0.5
func ServerErrorHandler(errorHandler ErrorHandler) ServerOption
func ServerFinalizer ¶ added in v0.0.5
func ServerFinalizer(f ...ServerFinalizerFunc) ServerOption
func ServerLimiter ¶ added in v0.3.0
func ServerLimiter(interval time.Duration, b int) ServerOption
Source Files
¶
Click to show internal directories.
Click to hide internal directories.