We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Context
// go-mir route interface define file // Site site interface info type Site struct { Chain `mir:"-"` Index func(Get, Chain) `mir:"/index/"` Assets func(Get, Context) `mir:"/assets/:name"` }
使用gin的代码生成器生成的代码如下
type _binding_ interface { Bind(*gin.Context) mir.Error } type _render_ interface { Render(*gin.Context) } type _default_ interface { Bind(*gin.Context, any) mir.Error Render(*gin.Context, any, mir.Error) } type Site interface { _default_ // Chain provide handlers chain for gin Chain() gin.HandlersChain Assets(*gin.Context) Index() mir.Error mustEmbedUnimplementedSiteServant() } // RegisterSiteServant register Site servant to gin func RegisterSiteServant(e *gin.Engine, s Site, m ...SiteChain) { var cc SiteChain if len(m) > 0 { cc = m[0] } else { cc = &UnimplementedSiteChain{} } router := e // use chain for router middlewares := s.Chain() router.Use(middlewares...) router.Handle("GET", "/assets/:name", s.Assets) router.Handle("GET", "/index/", append(cc.ChainIndex(), func(c *gin.Context) { select { case <-c.Request.Context().Done(): return default: } s.Render(c, nil, s.Index()) })...) }
具体示例请参考项目的examples。
The text was updated successfully, but these errors were encountered:
优化了Context的语义:
go-mir
handler(*gin.Context, *Request) (*Response, mir.Error)
Sorry, something went wrong.
alimy
No branches or pull requests
功能特性
Context
原语用于指示代码生成器 生成http引擎框架原生的handler作为接口方法;eg: gin as engine使用gin的代码生成器生成的代码如下
具体示例请参考项目的examples。
适配进度
The text was updated successfully, but these errors were encountered: