Documentation ¶
Index ¶
- func GetPool[REQ any]() sync.Pool
- func SetTranceId(traceId string) context.Context
- func TraceId(ctx context.Context) zap.Field
- type DeviceInfo
- type HttpContext
- type RequestContext
- func (c *RequestContext[REQ]) ContextWrapper() context.Context
- func (c *RequestContext[REQ]) Error(args ...interface{})
- func (c *RequestContext[REQ]) ErrorLog(err, originErr error, funcName string) error
- func (c *RequestContext[REQ]) HandleError(err error)
- func (c *RequestContext[REQ]) Method() string
- func (c *RequestContext[REQ]) NewDB(db *gorm.DB) *gorm.DB
- func (c *RequestContext[REQ]) StartSpan(name string, o ...trace.StartOption) (*RequestContext[REQ], *trace.Span)
- func (c *RequestContext[REQ]) WithContext(ctx context.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetTranceId ¶
Types ¶
type DeviceInfo ¶
type DeviceInfo struct { //设备 Device string `json:"device" gorm:"size:255"` Os string `json:"os" gorm:"size:255"` AppCode string `json:"appCode" gorm:"size:255"` AppVersion string `json:"appVersion" gorm:"size:255"` IP string `json:"ip" gorm:"size:255"` Lng string `json:"lng" gorm:"type:numeric(10,6)"` Lat string `json:"lat" gorm:"type:numeric(10,6)"` Area string `json:"area" gorm:"size:255"` UserAgent string `json:"userAgent" gorm:"size:255"` }
func Device ¶
func Device(infoHeader, area, localHeader, userAgent, ip string) *DeviceInfo
func DeviceFromHeader ¶
func DeviceFromHeader(r http.Header) *DeviceInfo
type HttpContext ¶
type HttpContext RequestContext[http.Request]
func (*HttpContext) SendHeader ¶
func (c *HttpContext) SendHeader(md metadata.MD) error
func (*HttpContext) SetCookie ¶
func (c *HttpContext) SetCookie(v string) error
func (*HttpContext) SetTrailer ¶
func (c *HttpContext) SetTrailer(md metadata.MD) error
func (*HttpContext) WriteHeader ¶
func (c *HttpContext) WriteHeader(k, v string) error
type RequestContext ¶
type RequestContext[REQ any] struct { context.Context TraceID string Token string *DeviceInfo request.RequestAt Request *REQ grpc.ServerTransportStream Internal string Values map[string]any }
func CtxFromContext ¶
func CtxFromContext[REQ any](ctx context.Context) *RequestContext[REQ]
func CtxWithRequest ¶
func (*RequestContext[REQ]) ContextWrapper ¶
func (c *RequestContext[REQ]) ContextWrapper() context.Context
func (*RequestContext[REQ]) Error ¶
func (c *RequestContext[REQ]) Error(args ...interface{})
func (*RequestContext[REQ]) ErrorLog ¶
func (c *RequestContext[REQ]) ErrorLog(err, originErr error, funcName string) error
func (*RequestContext[REQ]) HandleError ¶
func (c *RequestContext[REQ]) HandleError(err error)
func (*RequestContext[REQ]) Method ¶
func (c *RequestContext[REQ]) Method() string
func (*RequestContext[REQ]) StartSpan ¶
func (c *RequestContext[REQ]) StartSpan(name string, o ...trace.StartOption) (*RequestContext[REQ], *trace.Span)
func (*RequestContext[REQ]) WithContext ¶
func (c *RequestContext[REQ]) WithContext(ctx context.Context)
Click to show internal directories.
Click to hide internal directories.