|
|
|
// Code generated by go-mir. DO NOT EDIT.
|
|
|
|
// versions:
|
|
|
|
// - mir v4.0.0
|
|
|
|
|
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/alimy/mir/v4"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/rocboss/paopao-ce/internal/model/web"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Loose interface {
|
|
|
|
_default_
|
|
|
|
|
|
|
|
// Chain provide handlers chain for gin
|
|
|
|
Chain() gin.HandlersChain
|
|
|
|
|
|
|
|
TweetDetail(*web.TweetDetailReq) (*web.TweetDetailResp, mir.Error)
|
|
|
|
TweetComments(*web.TweetCommentsReq) (*web.TweetCommentsResp, mir.Error)
|
|
|
|
TopicList(*web.TopicListReq) (*web.TopicListResp, mir.Error)
|
|
|
|
GetUserProfile(*web.GetUserProfileReq) (*web.GetUserProfileResp, mir.Error)
|
|
|
|
GetUserTweets(*web.GetUserTweetsReq) (*web.GetUserTweetsResp, mir.Error)
|
|
|
|
Timeline(*web.TimelineReq) (*web.TimelineResp, mir.Error)
|
|
|
|
|
|
|
|
mustEmbedUnimplementedLooseServant()
|
|
|
|
}
|
|
|
|
|
|
|
|
// RegisterLooseServant register Loose servant to gin
|
|
|
|
func RegisterLooseServant(e *gin.Engine, s Loose) {
|
|
|
|
router := e.Group("v1")
|
|
|
|
// use chain for router
|
|
|
|
middlewares := s.Chain()
|
|
|
|
router.Use(middlewares...)
|
|
|
|
|
|
|
|
// register routes info to router
|
|
|
|
router.Handle("GET", "/post", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
req := new(web.TweetDetailReq)
|
|
|
|
if err := s.Bind(c, req); err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
resp, err := s.TweetDetail(req)
|
|
|
|
s.Render(c, resp, err)
|
|
|
|
})
|
|
|
|
router.Handle("GET", "/post/comments", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
req := new(web.TweetCommentsReq)
|
|
|
|
if err := s.Bind(c, req); err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
resp, err := s.TweetComments(req)
|
|
|
|
if err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var rv _render_ = resp
|
|
|
|
rv.Render(c)
|
|
|
|
})
|
|
|
|
router.Handle("GET", "/tags", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
req := new(web.TopicListReq)
|
|
|
|
if err := s.Bind(c, req); err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
resp, err := s.TopicList(req)
|
|
|
|
s.Render(c, resp, err)
|
|
|
|
})
|
|
|
|
router.Handle("GET", "/user/profile", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
req := new(web.GetUserProfileReq)
|
|
|
|
if err := s.Bind(c, req); err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
resp, err := s.GetUserProfile(req)
|
|
|
|
s.Render(c, resp, err)
|
|
|
|
})
|
|
|
|
router.Handle("GET", "/user/posts", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
req := new(web.GetUserTweetsReq)
|
|
|
|
if err := s.Bind(c, req); err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
resp, err := s.GetUserTweets(req)
|
|
|
|
if err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var rv _render_ = resp
|
|
|
|
rv.Render(c)
|
|
|
|
})
|
|
|
|
router.Handle("GET", "/posts", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
req := new(web.TimelineReq)
|
|
|
|
var bv _binding_ = req
|
|
|
|
if err := bv.Bind(c); err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
resp, err := s.Timeline(req)
|
|
|
|
if err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var rv _render_ = resp
|
|
|
|
rv.Render(c)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnimplementedLooseServant can be embedded to have forward compatible implementations.
|
|
|
|
type UnimplementedLooseServant struct{}
|
|
|
|
|
|
|
|
func (UnimplementedLooseServant) Chain() gin.HandlersChain {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedLooseServant) TweetDetail(req *web.TweetDetailReq) (*web.TweetDetailResp, mir.Error) {
|
|
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedLooseServant) TweetComments(req *web.TweetCommentsReq) (*web.TweetCommentsResp, mir.Error) {
|
|
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedLooseServant) TopicList(req *web.TopicListReq) (*web.TopicListResp, mir.Error) {
|
|
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedLooseServant) GetUserProfile(req *web.GetUserProfileReq) (*web.GetUserProfileResp, mir.Error) {
|
|
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedLooseServant) GetUserTweets(req *web.GetUserTweetsReq) (*web.GetUserTweetsResp, mir.Error) {
|
|
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedLooseServant) Timeline(req *web.TimelineReq) (*web.TimelineResp, mir.Error) {
|
|
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedLooseServant) mustEmbedUnimplementedLooseServant() {}
|