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.
paopao-ce/auto/api/v1/loose.go

233 lines
4.9 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:
}
var (
obj any
err mir.Error
)
req := new(web.TweetCommentsReq)
obj = req
if bv, ok := obj.(_binding_); !ok {
err = s.Bind(c, req)
} else {
err = bv.Bind(c)
}
if err != nil {
s.Render(c, nil, err)
return
}
obj, err = s.TweetComments(req)
if err != nil {
s.Render(c, nil, err)
return
}
if rv, ok := obj.(_render_); !ok {
s.Render(c, obj, nil)
} else {
rv.Render(c)
}
})
router.Handle("GET", "/tags", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
var (
obj any
err mir.Error
)
req := new(web.TopicListReq)
obj = req
if bv, ok := obj.(_binding_); !ok {
err = s.Bind(c, req)
} else {
err = bv.Bind(c)
}
if err != nil {
s.Render(c, nil, err)
return
}
obj, err = s.TopicList(req)
if err != nil {
s.Render(c, nil, err)
return
}
if rv, ok := obj.(_render_); !ok {
s.Render(c, obj, nil)
} else {
rv.Render(c)
}
})
router.Handle("GET", "/user/profile", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
var (
obj any
err mir.Error
)
req := new(web.GetUserProfileReq)
obj = req
if bv, ok := obj.(_binding_); !ok {
err = s.Bind(c, req)
} else {
err = bv.Bind(c)
}
if err != nil {
s.Render(c, nil, err)
return
}
obj, err = s.GetUserProfile(req)
if err != nil {
s.Render(c, nil, err)
return
}
if rv, ok := obj.(_render_); !ok {
s.Render(c, obj, nil)
} else {
rv.Render(c)
}
})
router.Handle("GET", "/user/posts", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
var (
obj any
err mir.Error
)
req := new(web.GetUserTweetsReq)
obj = req
if bv, ok := obj.(_binding_); !ok {
err = s.Bind(c, req)
} else {
err = bv.Bind(c)
}
if err != nil {
s.Render(c, nil, err)
return
}
obj, err = s.GetUserTweets(req)
if err != nil {
s.Render(c, nil, err)
return
}
if rv, ok := obj.(_render_); !ok {
s.Render(c, obj, nil)
} else {
rv.Render(c)
}
})
router.Handle("GET", "/posts", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
var (
obj any
err mir.Error
)
req := new(web.TimelineReq)
obj = req
if bv, ok := obj.(_binding_); !ok {
err = s.Bind(c, req)
} else {
err = bv.Bind(c)
}
if err != nil {
s.Render(c, nil, err)
return
}
obj, err = s.Timeline(req)
if err != nil {
s.Render(c, nil, err)
return
}
if rv, ok := obj.(_render_); !ok {
s.Render(c, obj, nil)
} else {
rv.Render(c)
}
})
}
// 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() {}