Releases: alimy/mir
Releases · alimy/mir
v3.0.0
mirc/v3.0.0
- adapter go-mir v3 spec implement.
v3.0.0-rc.1
- first rc version release
v3.0.0-beta.4
- fourth beta version releaase
v3.0.0-beta.2
- add external struct model that from external package as api's request/response support
v3.0.0-alpha.7
- add custom WatchCtxDone option for control whether generate watch context done code in register servants.
set WatchCtxDone(true)
// file: mirc/main.go
//go:generate go run main.go
func main() {
log.Println("generate code start")
opts := Options{
RunMode(InSerialMode),
GeneratorName(GeneratorGin),
WatchCtxDone(true),
SinkPath("auto"),
}
if err := Generate(opts); err != nil {
log.Fatal(err)
}
log.Println("generate code finish")
}
will generate watch context done code
// file: mirc/auto/v1/site.go
// RegisterSiteServant register Site servant to gin
func RegisterSiteServant(e *gin.Engine, s Site, r SiteRender) {
router := e.Group("v1")
// use chain for router
middlewares := s.Chain()
router.Use(middlewares...)
// register routes info to router
{
h := func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderArticles(c, s.Articles())
}
router.Handle("POST", "/articles/:category/", h)
router.Handle("GET", "/articles/:category/", h)
router.Handle("HEAD", "/articles/:category/", h)
}
router.Handle("GET", "/index/", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderIndex(c, s.Index())
})
}
set WatchCtxDone(false)
// file: mirc/main.go
//go:generate go run main.go
func main() {
log.Println("generate code start")
opts := Options{
RunMode(InSerialMode),
GeneratorName(GeneratorGin),
WatchCtxDone(false),
SinkPath("auto"),
}
if err := Generate(opts); err != nil {
log.Fatal(err)
}
log.Println("generate code finish")
}
will not generate watch context done code
// file: mirc/auto/v1/site.go
// RegisterSiteServant register Site servant to gin
func RegisterSiteServant(e *gin.Engine, s Site, r SiteRender) {
router := e.Group("v1")
// use chain for router
middlewares := s.Chain()
router.Use(middlewares...)
// register routes info to router
{
h := func(c *gin.Context) {
r.RenderArticles(c, s.Articles())
}
router.Handle("POST", "/articles/:category/", h)
router.Handle("GET", "/articles/:category/", h)
router.Handle("HEAD", "/articles/:category/", h)
}
router.Handle("GET", "/index/", func(c *gin.Context) {
r.RenderIndex(c, s.Index())
})
}
mirc/v3.0.0-alpha.6
- adapter go-mir v3.0.0-alpha.6
v3.0.0-alpha.6
- add hertz/echo/iris/fiber/macaron engine style generator support
- optimize gin/mux/chi/httprouter engine style gnerator add Request.Context().Done() support
- fixed gin/chi/hertz/httprouter/mux engine style generator miss a return segment in template
v3.0.0-alpha.5
- add chi/mux/httprouter engine style generator support
- optimize gin engine style generator code generate
v3.0.0-alpha.3
- add gin engine style generator for v3 spec base implement