mirror of https://github.com/rocboss/paopao-ce
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
3.7 KiB
139 lines
3.7 KiB
// 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
|
|
|
|
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/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)
|
|
s.Render(c, resp, err)
|
|
})
|
|
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)
|
|
s.Render(c, resp, err)
|
|
})
|
|
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)
|
|
s.Render(c, resp, err)
|
|
})
|
|
}
|
|
|
|
// UnimplementedLooseServant can be embedded to have forward compatible implementations.
|
|
type UnimplementedLooseServant struct{}
|
|
|
|
func (UnimplementedLooseServant) Chain() gin.HandlersChain {
|
|
return nil
|
|
}
|
|
|
|
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() {}
|