Documentation ¶
Index ¶
- Constants
- func AddIgnoreAuthPath(pathList ...string)
- func AddOpenApiPath(pathList ...string)
- func CheckIfIgnoreAuth(path string) bool
- func CheckIfOpenApi(path string) bool
- func CreateMetadataFromHeader(header http.Header) metadata.MD
- func LoggerHandler(ctx *Context)
- func RecoverHandler(ctx *Context)
- func Register(groupName string, handler interface{}) error
- func SetPrefix(prefix string)
- func Start(addr string) error
- func TraceHandler(ctx *Context)
- func Use(handlerChain ...HandleFunc)
- func WriteJson(w http.ResponseWriter, data interface{}, code ...int)
- func WriteProtobuf(w http.ResponseWriter, data proto.Message, code ...int)
- func WriteProtobufError(w http.ResponseWriter, errContent *dt.Error, code ...int)
- func WriteString(w http.ResponseWriter, data string, code ...int)
- func WriteSuccessData(w http.ResponseWriter, data interface{})
- type Context
- func (t *Context) Abort()
- func (t *Context) DATA(data interface{}) (int, error)
- func (t *Context) ERROR(data errors.Error) (int, error)
- func (t *Context) GetAccessKey() string
- func (t *Context) GetContentType() string
- func (t *Context) GetCopyOfBodyBytes() ([]byte, error)
- func (t *Context) GetHeader(k string) string
- func (t *Context) GetRequestBodyBytes() ([]byte, error)
- func (t *Context) GetSign() string
- func (t *Context) GetSignMethod() yc.SignMethod
- func (t *Context) GetTimestamp() int64
- func (t *Context) GetToken() string
- func (t *Context) IsJson() bool
- func (t *Context) IsPost() bool
- func (t *Context) IsProtoBuf() bool
- func (t *Context) Next()
- func (t *Context) SUCCESS(data interface{}) (int, error)
- func (t *Context) SetUserId(userId *dt.ID)
- func (t *Context) Write(data []byte) (int, error)
- func (t *Context) WriteHeaderCode(code int)
- func (t *Context) WriteJsonFailed(data interface{}) (int, error)
- func (t *Context) WriteJsonSuccess(data interface{}) (int, error)
- func (t *Context) WriteJsonWithCode(data interface{}, code int) (int, error)
- func (t *Context) WriteProtobufFailed(data proto.Message) (int, error)
- func (t *Context) WriteProtobufSuccess(data proto.Message) (int, error)
- func (t *Context) WriteProtobufWithCode(data proto.Message, code int) (int, error)
- type HandleFunc
- type JsonResponseWrapper
- type Router
- func (t *Router) AddIgnoreAuthPath(pathList ...string)
- func (t *Router) AddOpenApiPath(pathList ...string)
- func (t *Router) CheckIfIgnoreAuth(path string) bool
- func (t *Router) CheckIfOpenApi(path string) bool
- func (t *Router) Register(groupName string, handler interface{}) error
- func (t *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (t *Router) SetPrefix(prefix string)
- func (t *Router) Start(addr string) error
- func (t *Router) Use(handlerChain ...HandleFunc)
- type ValidatorHandler
Constants ¶
View Source
const (
HeaderContentType = "content-type"
)
Variables ¶
This section is empty.
Functions ¶
func AddIgnoreAuthPath ¶
func AddIgnoreAuthPath(pathList ...string)
func AddOpenApiPath ¶
func AddOpenApiPath(pathList ...string)
func CheckIfIgnoreAuth ¶
func CheckIfOpenApi ¶
func LoggerHandler ¶
func LoggerHandler(ctx *Context)
func RecoverHandler ¶
func RecoverHandler(ctx *Context)
func TraceHandler ¶
func TraceHandler(ctx *Context)
func Use ¶
func Use(handlerChain ...HandleFunc)
func WriteJson ¶
func WriteJson(w http.ResponseWriter, data interface{}, code ...int)
func WriteProtobuf ¶
func WriteProtobuf(w http.ResponseWriter, data proto.Message, code ...int)
func WriteProtobufError ¶
func WriteProtobufError(w http.ResponseWriter, errContent *dt.Error, code ...int)
func WriteString ¶
func WriteString(w http.ResponseWriter, data string, code ...int)
func WriteSuccessData ¶
func WriteSuccessData(w http.ResponseWriter, data interface{})
Types ¶
type Context ¶
type Context struct { Request *http.Request ResponseWriter http.ResponseWriter BodyContent []byte RpcContext context.Context StatusCode int // contains filtered or unexported fields }
func (*Context) GetAccessKey ¶
func (*Context) GetContentType ¶
func (*Context) GetCopyOfBodyBytes ¶
func (*Context) GetRequestBodyBytes ¶
func (*Context) GetSignMethod ¶
func (t *Context) GetSignMethod() yc.SignMethod
func (*Context) GetTimestamp ¶
func (*Context) IsProtoBuf ¶
func (*Context) WriteHeaderCode ¶
func (*Context) WriteJsonFailed ¶
func (*Context) WriteJsonSuccess ¶
func (*Context) WriteJsonWithCode ¶
func (*Context) WriteProtobufFailed ¶
func (*Context) WriteProtobufSuccess ¶
type HandleFunc ¶
type HandleFunc func(ctx *Context)
type JsonResponseWrapper ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func NewRouter ¶
func NewRouter(prefix string, handlerChain ...HandleFunc) *Router
func (*Router) AddIgnoreAuthPath ¶
func (*Router) AddOpenApiPath ¶
func (*Router) CheckIfIgnoreAuth ¶
func (*Router) CheckIfOpenApi ¶
func (*Router) Use ¶
func (t *Router) Use(handlerChain ...HandleFunc)
type ValidatorHandler ¶
type ValidatorHandler interface {
Validate() error
}
Click to show internal directories.
Click to hide internal directories.