Documentation
¶
Overview ¶
Package callbacks 把 pkg/callbacks 的切面接入 beauty 的 HTTP / gRPC 服务: 在每个请求前后触发已注册的 callbacks.Handler(全局或随 ctx 局部), 用于统一注入 trace / metrics / 日志,而无需改动业务 handler。
// 注册一个观测 handler
callbacks.AppendGlobalHandlers(myHandler)
// HTTP
webserver.New(addr, mux, webserver.WithMiddleware(cbmw.HTTPMiddleware()))
// gRPC
beauty.WithGrpcServer(addr, reg,
grpcserver.WithGrpcServerUnaryInterceptor(cbmw.UnaryServerInterceptor()))
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPMiddleware ¶
HTTPMiddleware 返回一个 HTTP 中间件,围绕每个请求触发 callbacks 切面: OnStart(请求进入)→ OnEnd(2xx-4xx)或 OnError(5xx)。
func StreamServerInterceptor ¶
func StreamServerInterceptor() grpc.StreamServerInterceptor
StreamServerInterceptor 返回一个 gRPC stream 拦截器,围绕流的生命周期触发 callbacks 切面。
func UnaryServerInterceptor ¶
func UnaryServerInterceptor() grpc.UnaryServerInterceptor
UnaryServerInterceptor 返回一个 gRPC unary 拦截器,围绕每次调用触发 callbacks 切面。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.