// Code generated by go-mir. DO NOT EDIT. package v1 import ( "net/http" "github.com/alimy/mir/v3" "github.com/gin-gonic/gin" "github.com/rocboss/paopao-ce/internal/model/web" ) type Pub interface { TopicList() mir.Error TweetComments() mir.Error TweetDetail(*web.TweetDetailReq) (*web.TweetDetailResp, mir.Error) SendCaptcha() mir.Error GetCaptcha() mir.Error Register() mir.Error Login() mir.Error Version() mir.Error mustEmbedUnimplementedPubServant() } type PubBinding interface { BindTweetDetail(*gin.Context) (*web.TweetDetailReq, mir.Error) mustEmbedUnimplementedPubBinding() } type PubRender interface { RenderTopicList(*gin.Context, mir.Error) RenderTweetComments(*gin.Context, mir.Error) RenderTweetDetail(*gin.Context, *web.TweetDetailResp, mir.Error) RenderSendCaptcha(*gin.Context, mir.Error) RenderGetCaptcha(*gin.Context, mir.Error) RenderRegister(*gin.Context, mir.Error) RenderLogin(*gin.Context, mir.Error) RenderVersion(*gin.Context, mir.Error) mustEmbedUnimplementedPubRender() } // RegisterPubServant register Pub servant to gin func RegisterPubServant(e *gin.Engine, s Pub, b PubBinding, r PubRender) { router := e.Group("v1") // register routes info to router router.Handle("GET", "/tags", func(c *gin.Context) { select { case <-c.Request.Context().Done(): return default: } r.RenderTopicList(c, s.TopicList()) }) router.Handle("GET", "/post/comments", func(c *gin.Context) { select { case <-c.Request.Context().Done(): return default: } r.RenderTweetComments(c, s.TweetComments()) }) router.Handle("GET", "/post", func(c *gin.Context) { select { case <-c.Request.Context().Done(): return default: } req, err := b.BindTweetDetail(c) if err != nil { r.RenderTweetDetail(c, nil, err) return } resp, err := s.TweetDetail(req) r.RenderTweetDetail(c, resp, err) }) router.Handle("POST", "/captcha", func(c *gin.Context) { select { case <-c.Request.Context().Done(): return default: } r.RenderSendCaptcha(c, s.SendCaptcha()) }) router.Handle("GET", "/captcha", func(c *gin.Context) { select { case <-c.Request.Context().Done(): return default: } r.RenderGetCaptcha(c, s.GetCaptcha()) }) router.Handle("POST", "/auth/register", func(c *gin.Context) { select { case <-c.Request.Context().Done(): return default: } r.RenderRegister(c, s.Register()) }) router.Handle("POST", "/auth/login", func(c *gin.Context) { select { case <-c.Request.Context().Done(): return default: } r.RenderLogin(c, s.Login()) }) router.Handle("GET", "/", func(c *gin.Context) { select { case <-c.Request.Context().Done(): return default: } r.RenderVersion(c, s.Version()) }) } // UnimplementedPubServant can be embedded to have forward compatible implementations. type UnimplementedPubServant struct { } func (UnimplementedPubServant) TopicList() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedPubServant) TweetComments() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedPubServant) TweetDetail(req *web.TweetDetailReq) (*web.TweetDetailResp, mir.Error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedPubServant) SendCaptcha() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedPubServant) GetCaptcha() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedPubServant) Register() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedPubServant) Login() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedPubServant) Version() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedPubServant) mustEmbedUnimplementedPubServant() {} // UnimplementedPubRender can be embedded to have forward compatible implementations. type UnimplementedPubRender struct { RenderAny func(*gin.Context, any, mir.Error) } func (r *UnimplementedPubRender) RenderTopicList(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedPubRender) RenderTweetComments(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedPubRender) RenderTweetDetail(c *gin.Context, data *web.TweetDetailResp, err mir.Error) { r.RenderAny(c, data, err) } func (r *UnimplementedPubRender) RenderSendCaptcha(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedPubRender) RenderGetCaptcha(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedPubRender) RenderRegister(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedPubRender) RenderLogin(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedPubRender) RenderVersion(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedPubRender) mustEmbedUnimplementedPubRender() {} // UnimplementedPubBinding can be embedded to have forward compatible implementations. type UnimplementedPubBinding struct { BindAny func(*gin.Context, any) mir.Error } func (b *UnimplementedPubBinding) BindTweetDetail(c *gin.Context) (*web.TweetDetailReq, mir.Error) { obj := new(web.TweetDetailReq) err := b.BindAny(c, obj) return obj, err } func (b *UnimplementedPubBinding) mustEmbedUnimplementedPubBinding() {}