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.
119 lines
3.0 KiB
119 lines
3.0 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 Pub interface {
|
|
_default_
|
|
|
|
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("POST", "/captcha", func(c *gin.Context) {
|
|
select {
|
|
case <-c.Request.Context().Done():
|
|
return
|
|
default:
|
|
}
|
|
req := new(web.SendCaptchaReq)
|
|
if err := s.Bind(c, req); 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:
|
|
}
|
|
|
|
resp, err := s.GetCaptcha()
|
|
s.Render(c, resp, err)
|
|
})
|
|
router.Handle("POST", "/auth/register", func(c *gin.Context) {
|
|
select {
|
|
case <-c.Request.Context().Done():
|
|
return
|
|
default:
|
|
}
|
|
req := new(web.RegisterReq)
|
|
if err := s.Bind(c, req); err != nil {
|
|
s.Render(c, nil, err)
|
|
return
|
|
}
|
|
resp, err := s.Register(req)
|
|
s.Render(c, resp, err)
|
|
})
|
|
router.Handle("POST", "/auth/login", func(c *gin.Context) {
|
|
select {
|
|
case <-c.Request.Context().Done():
|
|
return
|
|
default:
|
|
}
|
|
req := new(web.LoginReq)
|
|
if err := s.Bind(c, req); err != nil {
|
|
s.Render(c, nil, err)
|
|
return
|
|
}
|
|
resp, err := s.Login(req)
|
|
s.Render(c, resp, err)
|
|
})
|
|
router.Handle("GET", "/", func(c *gin.Context) {
|
|
select {
|
|
case <-c.Request.Context().Done():
|
|
return
|
|
default:
|
|
}
|
|
|
|
resp, err := s.Version()
|
|
s.Render(c, resp, err)
|
|
})
|
|
}
|
|
|
|
// UnimplementedPubServant can be embedded to have forward compatible implementations.
|
|
type UnimplementedPubServant struct{}
|
|
|
|
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() {}
|