tot

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: MIT Imports: 7 Imported by: 0

README

tot

介绍

参考go-kit与httprouter实现的go web开发工具

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterFunction

type AfterFunction func(beforeCtx context.Context, w http.ResponseWriter) (ctx context.Context)

AfterFunction 请求后方法,请求后处理

type BeforeFunction

type BeforeFunction func(beforeCtx context.Context, r *http.Request) (ctx context.Context)

BeforeFunction 请求前方法,请求前处理

type Endpoint

type Endpoint func(ctx context.Context, request interface{}) (response interface{}, err error)

Endpoint 端点,传入上下文与请求,返回响应与错误信息

type ErrorFunction

type ErrorFunction func(ctx context.Context, w http.ResponseWriter, err error)

ErrorFunction 错误方法,错误信息

type FinalizerFunction added in v0.0.6

type FinalizerFunction func(ctx context.Context, w http.ResponseWriter, r *http.Request)

FinalizerFunction 终结方法,请求响应数据解析

type GRPCAfterFunction added in v0.0.4

type GRPCAfterFunction func(ctx context.Context, header *metadata.MD, trailer *metadata.MD) (retCtx context.Context)

GRPCAfterFunction 请求后方法,请求后处理

type GRPCBeforeFunction added in v0.0.4

type GRPCBeforeFunction func(ctx context.Context, md metadata.MD) (retCtx context.Context)

GRPCBeforeFunction 请求前方法,请求前处理

type GRPCFinalizerFunction added in v0.0.6

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

GRPCFinalizerFunction 终结方法,请求响应数据解析

type GRPCHandler added in v0.0.4

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

GRPCHandler 处理器

func NewGRPCHandler added in v0.0.4

func NewGRPCHandler(endpoint Endpoint, request GRPCRequestFunction, response GRPCResponseFunction, option ...GRPCHandlerOption) (handler *GRPCHandler)

NewGRPCHandler 新建处理器

func (GRPCHandler) ServeGRPC added in v0.0.4

func (g GRPCHandler) ServeGRPC(ctx context.Context, request interface{}) (retCtx context.Context, response interface{}, err error)

ServeGRPC 实现GRPC处理器

type GRPCHandlerOption added in v0.0.4

type GRPCHandlerOption func(handler *GRPCHandler)

GRPCHandlerOption 处理器操作

func GRPCAfterOption added in v0.0.4

func GRPCAfterOption(after ...GRPCAfterFunction) (handler GRPCHandlerOption)

GRPCAfterOption 处理后操作

func GRPCBeforeOption added in v0.0.4

func GRPCBeforeOption(before ...GRPCBeforeFunction) (handler GRPCHandlerOption)

GRPCBeforeOption 处理前操作

func GRPCFinalizerOption added in v0.0.6

func GRPCFinalizerOption(finalizer ...GRPCFinalizerFunction) (handler GRPCHandlerOption)

GRPCFinalizerOption 终结操作

type GRPCRequestFunction added in v0.0.4

type GRPCRequestFunction func(ctx context.Context, r interface{}) (request interface{}, err error)

GRPCRequestFunction 请求方法,请求数据解析

type GRPCResponseFunction added in v0.0.4

type GRPCResponseFunction func(ctx context.Context, w interface{}) (response interface{}, err error)

GRPCResponseFunction 响应方法,响应数据解析

type Handler

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

Handler 处理器

func NewHandler

func NewHandler(endpoint Endpoint, request RequestFunction, response ResponseFunction, option ...HandlerOption) (handler *Handler)

NewHandler 新建处理器

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP 实现HTTP处理器

type HandlerOption

type HandlerOption func(handler *Handler)

HandlerOption 处理器操作

func AfterOption

func AfterOption(after ...AfterFunction) (handler HandlerOption)

AfterOption 处理后操作

func BeforeOption

func BeforeOption(before ...BeforeFunction) (handler HandlerOption)

BeforeOption 处理前操作

func ErrorOption

func ErrorOption(error ErrorFunction) (handler HandlerOption)

ErrorOption 错误操作

func FinalizerOption added in v0.0.6

func FinalizerOption(finalizer ...FinalizerFunction) (handler HandlerOption)

FinalizerOption 终结操作

type Middleware

type Middleware func(Endpoint) Endpoint

Middleware 中间件,端点中间件调用

func Chain

func Chain(outer Middleware, others ...Middleware) Middleware

Chain 中间件链式调用

type PanicHandler added in v0.0.6

type PanicHandler func(w http.ResponseWriter, r *http.Request, err interface{})

PanicHandler 错误处理器

type RequestFunction

type RequestFunction func(ctx context.Context, r *http.Request) (request interface{}, err error)

RequestFunction 请求方法,请求数据解析

type ResponseFunction

type ResponseFunction func(ctx context.Context, w http.ResponseWriter, response interface{}) (err error)

ResponseFunction 响应方法,响应数据解析

type Router

type Router struct {
	NotFound     http.Handler // 未找到处理器
	PanicHandler PanicHandler // 错误处理器
	// contains filtered or unexported fields
}

Router 路由器

func NewRouter

func NewRouter() *Router

NewRouter 创建路由器

func (*Router) DELETE added in v0.0.3

func (r *Router) DELETE(path string, handler http.Handler)

DELETE DELETE处理器

func (*Router) GET added in v0.0.3

func (r *Router) GET(path string, handler http.Handler)

GET GET处理器

func (*Router) HEAD added in v0.0.3

func (r *Router) HEAD(path string, handle http.Handler)

HEAD HEAD处理器

func (*Router) Handler

func (r *Router) Handler(method, path string, handler http.Handler)

Handler 处理器

func (*Router) HandlerFunc added in v0.0.3

func (r *Router) HandlerFunc(method, path string, handler http.HandlerFunc)

HandlerFunc 处理器

func (*Router) OPTIONS added in v0.0.3

func (r *Router) OPTIONS(path string, handle http.Handler)

OPTIONS OPTIONS处理器

func (*Router) PATCH added in v0.0.3

func (r *Router) PATCH(path string, handler http.Handler)

PATCH PATCH处理器

func (*Router) POST added in v0.0.3

func (r *Router) POST(path string, handler http.Handler)

POST POST处理器

func (*Router) PUT added in v0.0.3

func (r *Router) PUT(path string, handler http.Handler)

PUT PUT处理器

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP 实现HTTP处理器

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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