Documentation ¶
Index ¶
- Constants
- Variables
- func ErrorEncoder(ctx context.Context, err error, w http.ResponseWriter)
- func GetServer() *luchen.HTTPServer
- func NewHandler(e luchen.Endpoint, dec httptransport.DecodeRequestFunc, ...) *luchen.HTTPTransportServer
- func ResponseWrapper(data interface{}) interface{}
- func WriteData(ctx context.Context, w http.ResponseWriter, httpCode int, data any)
Constants ¶
View Source
const ( StatusOK = 0 // AdminAPI 管理后台接口前缀 AdminAPI = "/admin" // API 接口前缀 API = "/api" // OpenAPI 不需要鉴权的接口前缀 OpenAPI = API + "/open" RequestHeaderAdminUID = "X-Admin-UID" RequestHeaderAdminToken = "X-Admin-Token" ResponseHeaderServer = "Server" ResponseHeaderRefreshToken = "X-Refresh-Token" )
Variables ¶
View Source
var GzipMiddleware = middleware.Compress(5, "gzip")
Functions ¶
func ErrorEncoder ¶
func ErrorEncoder(ctx context.Context, err error, w http.ResponseWriter)
ErrorEncoder 统一异常处理
func GetServer ¶
func GetServer() *luchen.HTTPServer
func NewHandler ¶
func NewHandler(e luchen.Endpoint, dec httptransport.DecodeRequestFunc, enc httptransport.EncodeResponseFunc, options ...httptransport.ServerOption) *luchen.HTTPTransportServer
NewHandler 创建 http handler
func ResponseWrapper ¶
func ResponseWrapper(data interface{}) interface{}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.