|
|
|
// 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 _binding_ interface {
|
|
|
|
Bind(*gin.Context) mir.Error
|
|
|
|
}
|
|
|
|
|
|
|
|
type _render_ interface {
|
|
|
|
Render(*gin.Context)
|
|
|
|
}
|
|
|
|
|
|
|
|
type _default_ interface {
|
|
|
|
Bind(*gin.Context, any) mir.Error
|
|
|
|
Render(*gin.Context, any, mir.Error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type Pub interface {
|
|
|
|
_default_
|
|
|
|
|
|
|
|
TweetDetail(*web.TweetDetailReq) (*web.TweetDetailResp, mir.Error)
|
|
|
|
SendCaptcha(*web.SendCaptchaReq) mir.Error
|
|
|
|
GetCaptcha() (*web.GetCaptchaResp, mir.Error)
|
|
|
|
Register(*web.RegisterReq) (*web.RegisterResp, mir.Error)
|
|
|
|
Login(*web.LoginReq) (*web.LoginResp, mir.Error)
|
|
|
|
Version() (*web.VersionResp, mir.Error)
|
|
|
|
|
|
|
|
mustEmbedUnimplementedPubServant()
|
|
|
|
}
|
|
|
|
|
|
|
|
// RegisterPubServant register Pub servant to gin
|
|
|
|
func RegisterPubServant(e *gin.Engine, s Pub) {
|
|
|
|
router := e.Group("v1")
|
|
|
|
|
|
|
|
// register routes info to router
|
|
|
|
router.Handle("GET", "/post", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
obj any
|
|
|
|
err mir.Error
|
|
|
|
)
|
|
|
|
req := new(web.TweetDetailReq)
|
|
|
|
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.TweetDetail(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("POST", "/captcha", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
obj any
|
|
|
|
err mir.Error
|
|
|
|
)
|
|
|
|
req := new(web.SendCaptchaReq)
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
s.Render(c, nil, s.SendCaptcha(req))
|
|
|
|
})
|
|
|
|
router.Handle("GET", "/captcha", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
obj any
|
|
|
|
err mir.Error
|
|
|
|
)
|
|
|
|
|
|
|
|
obj, err = s.GetCaptcha()
|
|
|
|
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("POST", "/auth/register", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
obj any
|
|
|
|
err mir.Error
|
|
|
|
)
|
|
|
|
req := new(web.RegisterReq)
|
|
|
|
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.Register(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("POST", "/auth/login", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
obj any
|
|
|
|
err mir.Error
|
|
|
|
)
|
|
|
|
req := new(web.LoginReq)
|
|
|
|
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.Login(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", "/", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
obj any
|
|
|
|
err mir.Error
|
|
|
|
)
|
|
|
|
|
|
|
|
obj, err = s.Version()
|
|
|
|
if err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if rv, ok := obj.(_render_); !ok {
|
|
|
|
s.Render(c, obj, nil)
|
|
|
|
} else {
|
|
|
|
rv.Render(c)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnimplementedPubServant can be embedded to have forward compatible implementations.
|
|
|
|
type UnimplementedPubServant struct{}
|
|
|
|
|
|
|
|
func (UnimplementedPubServant) TweetDetail(req *web.TweetDetailReq) (*web.TweetDetailResp, mir.Error) {
|
|
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedPubServant) SendCaptcha(req *web.SendCaptchaReq) mir.Error {
|
|
|
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedPubServant) GetCaptcha() (*web.GetCaptchaResp, mir.Error) {
|
|
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedPubServant) Register(req *web.RegisterReq) (*web.RegisterResp, mir.Error) {
|
|
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedPubServant) Login(req *web.LoginReq) (*web.LoginResp, mir.Error) {
|
|
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedPubServant) Version() (*web.VersionResp, mir.Error) {
|
|
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedPubServant) mustEmbedUnimplementedPubServant() {}
|