water

package module
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: MIT Imports: 12 Imported by: 6

README

go-water 是一款设计层面的框架,帮助 web 框架(gin,iris,beego,echo等)实现隔离友好,设计优美的系统,通过一系列接口、规范、约定,深度解耦系统。

星星增长趋势

Stargazers over time

安装

go get -u github.com/go-water/water

技术概览

  • zap 日志
  • rsa 加密,openssl 生成公/私钥对
  • jwt 登陆认证
  • errors 自定义处理
  • pool 管理请求参数
  • option 配置修改

样例仓库

官方文档

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidKey = errors.New("key is invalid")
)

Functions

func Error added in v0.2.8

func Error(msg string, fields ...zap.Field)

func Info added in v0.2.8

func Info(msg string, fields ...zap.Field)

func InitZap added in v0.2.8

func InitZap()

func NewLogger added in v0.2.8

func NewLogger() *zap.Logger

func ParseFromRequest added in v0.2.6

func ParseFromRequest(req *http.Request, publicKeyPath string) (uniqueUser, signature string, err error)

ParseFromRequest 兼容 http,ws

func SetAuthToken added in v0.2.0

func SetAuthToken(uniqueUser, privateKeyPath string, expire time.Duration) (tokenString string, err error)

func Warn added in v0.2.8

func Warn(msg string, fields ...zap.Field)

Types

type Endpoint

type Endpoint func(ctx context.Context, req any) (any, error)

type ErrorHandler

type ErrorHandler interface {
	Handle(ctx context.Context, err error)
}

type ErrorHandlerFunc

type ErrorHandlerFunc func(ctx context.Context, err error)

func (ErrorHandlerFunc) Handle

func (f ErrorHandlerFunc) Handle(ctx context.Context, err error)

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 LogErrorHandler

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

func NewLogErrorHandler

func NewLogErrorHandler(l *zap.Logger, n string) *LogErrorHandler

func (*LogErrorHandler) Handle

func (h *LogErrorHandler) Handle(ctx context.Context, err error)

type Server

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

func (*Server) GetLogger added in v0.0.22

func (s *Server) GetLogger() *zap.Logger

func (*Server) ServerWater added in v0.0.16

func (s *Server) ServerWater(ctx context.Context, req any) (resp any, err error)

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 ServerFinalizerFunc func(ctx context.Context, err error)

type ServerOption

type ServerOption func(*Server)

func ServerErrorHandler added in v0.0.5

func ServerErrorHandler(errorHandler ErrorHandler) ServerOption

func ServerFinalizer added in v0.0.5

func ServerFinalizer(f ...ServerFinalizerFunc) ServerOption

type Service

type Service interface {
	Endpoint() Endpoint
	Name(srv Service) string
	SetLogger(l *zap.Logger)
}

Jump to

Keyboard shortcuts

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