Releases: alimy/mir
Releases · alimy/mir
v4.2.0-alpha.6
add service package.
v4.1.0
Added
- add
gin
engine support forContext
primitive logic - add
hertz
engine support forContext
primitive logic - add
chi
engine support forContext
primitive logic - add
mux
engine support forContext
primitive logic - add
httprouter
engine supportContext
primitive logic - add
echo
engine support forContext
primitive logic - add
iris
engine support forContext
primitive logic - add
fiber
engine support forContext
primitive logic - add
macaron
engine support forContext
primitive logic
mirc/v4.1.0
- adapter for go-mir v4.1.0.
v4.1.0-rc.1
- prepare to release v4.1.0
v4.1.0-beta.1
add Context primitive indicator use Engine's raw handler as method
adpate for engine
- gin
- chi
- echo
- fiber
- hertz
- httprouter
- iris
- macaron
- mux
mirc/v4.1.0-beta.1
- adapte for go-mir v4.1.0-beta.1
v4.1.0-alpha.3
- add Context primitive support for hertz engine code generate
v4.1.0-alpha.2
v4.1.0-alpha.1
- add
Context
primitive support for gin engine code generate
Usage:
// 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())
})...)
}