mir
mir copied to clipboard
Mir is a toolkit for register method handler to http engine router(eg: gin,echo,iris,mux,httprouter) use struct tag info.
需求: - 添加 net/http: ServeMux 的支持 方案1: - 只支持go1.22+ 的 net/http: ServeMux 方案2: - 通过选项支持
### 源由: 最近在集成OpenTelemetry到使用gin的项目中,使用[otelgin](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/github.com/gin-gonic/gin/otelgin)与[otelgorm](https://github.com/uptrace/opentelemetry-go-extra/tree/main/otelgorm)进行 Trace链路追踪(详情请见[paopao-ce](https://github.com/rocboss/paopao-ce/tree/x/opentelemetry)),集成过程中遇到一些问题,比如使用go-mir生成的代码默认是不带Engine `Context`或 HTTP Request `Context`,而`otelgin`是使用 HTTP Request `Context`来透传OpenTelemetry相关上下文的,如果需要将从HTTP Request 到DB数据库之间的链路串连在一起,就需要显示的`Context`来透传链路的上下文信息,也就是需要显示获取最原始请求的HTTP Request `Context`。目前go-mir支持代码生成的接口显示带有Engine `Context`,比如Gin的`*gin.Context`,只需要在接口定义处添加`Context`原语,一般HTTP Request `Context`可以从Engine `Context`中获取。还有一种获取HTTP Request `Context`的方法就是在请求参数Bind的时候获取,比如在默认的Bind函数中获取HTTP Request `Context`后赋值给接口的请求参数。以上两种方法都能满足需求,但都是采用了取巧的法子来完成,本提按提供一种直接在生成代码的接口方法中直接带上HTTP Request `Context`来满足需求。 ### 需求: * 使用`UseRequestContext` Option选项开启添加HTTP...
### Add Thrift idl as DSL support for go-mir ```thrift namespace go car include "../base/common.thrift" include "../base/car.thrift" struct AdminCreateCarRequest { 1: string plate_num (api.raw = "plate_num", api.vd = "len($) >...
Bumps [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin) from 1.9.1 to 1.10.0. Release notes Sourced from github.com/gin-gonic/gin's releases. v1.10.0 Changelog Features 5f458dd1a6d631f324e4af9a4f5429ffdf199342: feat(auth): add proxy-server authentication (#3877) (@EndlessParadox1) 7a865dcf1dbe6ec52e074b1ddce830d278eb72cf: feat(bind): ShouldBindBodyWith shortcut and change doc (#3871)...