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.
227 lines
5.6 KiB
227 lines
5.6 KiB
2 years ago
|
// 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"
|
||
|
)
|
||
|
|
||
2 years ago
|
type Pub interface {
|
||
2 years ago
|
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
|
||
|
|
||
2 years ago
|
mustEmbedUnimplementedPubServant()
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
type PubBinding interface {
|
||
2 years ago
|
BindTweetDetail(*gin.Context) (*web.TweetDetailReq, mir.Error)
|
||
|
|
||
2 years ago
|
mustEmbedUnimplementedPubBinding()
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
type PubRender interface {
|
||
2 years ago
|
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)
|
||
|
|
||
2 years ago
|
mustEmbedUnimplementedPubRender()
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
// RegisterPubServant register Pub servant to gin
|
||
|
func RegisterPubServant(e *gin.Engine, s Pub, b PubBinding, r PubRender) {
|
||
2 years ago
|
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())
|
||
|
})
|
||
|
|
||
|
}
|
||
|
|
||
2 years ago
|
// UnimplementedPubServant can be embedded to have forward compatible implementations.
|
||
|
type UnimplementedPubServant struct {
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedPubServant) TopicList() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedPubServant) TweetComments() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedPubServant) TweetDetail(req *web.TweetDetailReq) (*web.TweetDetailResp, mir.Error) {
|
||
2 years ago
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedPubServant) SendCaptcha() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedPubServant) GetCaptcha() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedPubServant) Register() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedPubServant) Login() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedPubServant) Version() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedPubServant) mustEmbedUnimplementedPubServant() {}
|
||
2 years ago
|
|
||
2 years ago
|
// UnimplementedPubRender can be embedded to have forward compatible implementations.
|
||
|
type UnimplementedPubRender struct {
|
||
2 years ago
|
RenderAny func(*gin.Context, any, mir.Error)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedPubRender) RenderTopicList(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedPubRender) RenderTweetComments(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedPubRender) RenderTweetDetail(c *gin.Context, data *web.TweetDetailResp, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, data, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedPubRender) RenderSendCaptcha(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedPubRender) RenderGetCaptcha(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedPubRender) RenderRegister(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedPubRender) RenderLogin(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedPubRender) RenderVersion(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedPubRender) mustEmbedUnimplementedPubRender() {}
|
||
2 years ago
|
|
||
2 years ago
|
// UnimplementedPubBinding can be embedded to have forward compatible implementations.
|
||
|
type UnimplementedPubBinding struct {
|
||
2 years ago
|
BindAny func(*gin.Context, any) mir.Error
|
||
|
}
|
||
|
|
||
2 years ago
|
func (b *UnimplementedPubBinding) BindTweetDetail(c *gin.Context) (*web.TweetDetailReq, mir.Error) {
|
||
2 years ago
|
obj := new(web.TweetDetailReq)
|
||
|
err := b.BindAny(c, obj)
|
||
|
return obj, err
|
||
|
}
|
||
|
|
||
2 years ago
|
func (b *UnimplementedPubBinding) mustEmbedUnimplementedPubBinding() {}
|