// 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 WebPub 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 mustEmbedUnimplementedWebPubServant() } type WebPubBinding interface { BindTweetDetail(*gin.Context) (*web.TweetDetailReq, mir.Error) mustEmbedUnimplementedWebPubBinding() } type WebPubRender 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) mustEmbedUnimplementedWebPubRender() } // RegisterWebPubServant register WebPub servant to gin func RegisterWebPubServant(e *gin.Engine, s WebPub, b WebPubBinding, r WebPubRender) { 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()) }) } // UnimplementedWebPubServant can be embedded to have forward compatible implementations. type UnimplementedWebPubServant struct { } func (UnimplementedWebPubServant) TopicList() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedWebPubServant) TweetComments() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedWebPubServant) TweetDetail(req *web.TweetDetailReq) (*web.TweetDetailResp, mir.Error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedWebPubServant) SendCaptcha() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedWebPubServant) GetCaptcha() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedWebPubServant) Register() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedWebPubServant) Login() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedWebPubServant) Version() mir.Error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } func (UnimplementedWebPubServant) mustEmbedUnimplementedWebPubServant() {} // UnimplementedWebPubRender can be embedded to have forward compatible implementations. type UnimplementedWebPubRender struct { RenderAny func(*gin.Context, any, mir.Error) } func (r *UnimplementedWebPubRender) RenderTopicList(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedWebPubRender) RenderTweetComments(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedWebPubRender) RenderTweetDetail(c *gin.Context, data *web.TweetDetailResp, err mir.Error) { r.RenderAny(c, data, err) } func (r *UnimplementedWebPubRender) RenderSendCaptcha(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedWebPubRender) RenderGetCaptcha(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedWebPubRender) RenderRegister(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedWebPubRender) RenderLogin(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedWebPubRender) RenderVersion(c *gin.Context, err mir.Error) { r.RenderAny(c, nil, err) } func (r *UnimplementedWebPubRender) mustEmbedUnimplementedWebPubRender() {} // UnimplementedWebPubBinding can be embedded to have forward compatible implementations. type UnimplementedWebPubBinding struct { BindAny func(*gin.Context, any) mir.Error } func (b *UnimplementedWebPubBinding) BindTweetDetail(c *gin.Context) (*web.TweetDetailReq, mir.Error) { obj := new(web.TweetDetailReq) err := b.BindAny(c, obj) return obj, err } func (b *UnimplementedWebPubBinding) mustEmbedUnimplementedWebPubBinding() {}