|
|
@ -3,9 +3,10 @@
|
|
|
|
package v1
|
|
|
|
package v1
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
|
|
gin "github.com/gin-gonic/gin"
|
|
|
|
"github.com/alimy/mir/v3"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type AgentInfo struct {
|
|
|
|
type AgentInfo struct {
|
|
|
@ -37,25 +38,25 @@ type WebCore interface {
|
|
|
|
// Chain provide handlers chain for gin
|
|
|
|
// Chain provide handlers chain for gin
|
|
|
|
Chain() gin.HandlersChain
|
|
|
|
Chain() gin.HandlersChain
|
|
|
|
|
|
|
|
|
|
|
|
Index(c *gin.Context) error
|
|
|
|
Index(c *gin.Context) mir.Error
|
|
|
|
Articles(c *gin.Context) error
|
|
|
|
Articles(c *gin.Context) mir.Error
|
|
|
|
Login(c *gin.Context, req *LoginReq) (*LoginResp, error)
|
|
|
|
Login(c *gin.Context, req *LoginReq) (*LoginResp, mir.Error)
|
|
|
|
Logout(c *gin.Context) error
|
|
|
|
Logout(c *gin.Context) mir.Error
|
|
|
|
|
|
|
|
|
|
|
|
mustEmbedUnimplementedWebCoreServant()
|
|
|
|
mustEmbedUnimplementedWebCoreServant()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type WebCoreBinding interface {
|
|
|
|
type WebCoreBinding interface {
|
|
|
|
BindLogin(c *gin.Context) (*LoginReq, error)
|
|
|
|
BindLogin(c *gin.Context) (*LoginReq, mir.Error)
|
|
|
|
|
|
|
|
|
|
|
|
mustEmbedUnimplementedWebCoreBinding()
|
|
|
|
mustEmbedUnimplementedWebCoreBinding()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type WebCoreRender interface {
|
|
|
|
type WebCoreRender interface {
|
|
|
|
RenderIndex(c *gin.Context, err error)
|
|
|
|
RenderIndex(c *gin.Context, err mir.Error)
|
|
|
|
RenderArticles(c *gin.Context, err error)
|
|
|
|
RenderArticles(c *gin.Context, err mir.Error)
|
|
|
|
RenderLogin(c *gin.Context, data *LoginResp, err error)
|
|
|
|
RenderLogin(c *gin.Context, data *LoginResp, err mir.Error)
|
|
|
|
RenderLogout(c *gin.Context, err error)
|
|
|
|
RenderLogout(c *gin.Context, err mir.Error)
|
|
|
|
|
|
|
|
|
|
|
|
mustEmbedUnimplementedWebCoreRender()
|
|
|
|
mustEmbedUnimplementedWebCoreRender()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -92,37 +93,37 @@ type UnimplementedWebCoreServant struct{}
|
|
|
|
|
|
|
|
|
|
|
|
// UnimplementedWebCoreBinding can be embedded to have forward compatible implementations.
|
|
|
|
// UnimplementedWebCoreBinding can be embedded to have forward compatible implementations.
|
|
|
|
type UnimplementedWebCoreBinding struct {
|
|
|
|
type UnimplementedWebCoreBinding struct {
|
|
|
|
BindAny func(*gin.Context, any) error
|
|
|
|
BindAny func(*gin.Context, any) mir.Error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UnimplementedWebCoreRender can be embedded to have forward compatible implementations.
|
|
|
|
// UnimplementedWebCoreRender can be embedded to have forward compatible implementations.
|
|
|
|
type UnimplementedWebCoreRender struct {
|
|
|
|
type UnimplementedWebCoreRender struct {
|
|
|
|
RenderAny func(*gin.Context, any, error)
|
|
|
|
RenderAny func(*gin.Context, any, mir.Error)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (UnimplementedWebCoreServant) Chain() gin.HandlersChain {
|
|
|
|
func (UnimplementedWebCoreServant) Chain() gin.HandlersChain {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (UnimplementedWebCoreServant) Index(c *gin.Context) error {
|
|
|
|
func (UnimplementedWebCoreServant) Index(c *gin.Context) mir.Error {
|
|
|
|
return errors.New("method Index not implemented")
|
|
|
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (UnimplementedWebCoreServant) Articles(c *gin.Context) error {
|
|
|
|
func (UnimplementedWebCoreServant) Articles(c *gin.Context) mir.Error {
|
|
|
|
return errors.New("method Index not implemented")
|
|
|
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (UnimplementedWebCoreServant) Login(c *gin.Context, req *LoginReq) (*LoginResp, error) {
|
|
|
|
func (UnimplementedWebCoreServant) Login(c *gin.Context, req *LoginReq) (*LoginResp, mir.Error) {
|
|
|
|
return nil, errors.New("method Login not implemented")
|
|
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (UnimplementedWebCoreServant) Logout(c *gin.Context) error {
|
|
|
|
func (UnimplementedWebCoreServant) Logout(c *gin.Context) mir.Error {
|
|
|
|
return errors.New("method Logout not implemented")
|
|
|
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (UnimplementedWebCoreServant) mustEmbedUnimplementedWebCoreServant() {}
|
|
|
|
func (UnimplementedWebCoreServant) mustEmbedUnimplementedWebCoreServant() {}
|
|
|
|
|
|
|
|
|
|
|
|
func (b *UnimplementedWebCoreBinding) BindLogin(c *gin.Context) (*LoginReq, error) {
|
|
|
|
func (b *UnimplementedWebCoreBinding) BindLogin(c *gin.Context) (*LoginReq, mir.Error) {
|
|
|
|
obj := new(LoginReq)
|
|
|
|
obj := new(LoginReq)
|
|
|
|
err := b.BindAny(c, obj)
|
|
|
|
err := b.BindAny(c, obj)
|
|
|
|
return obj, err
|
|
|
|
return obj, err
|
|
|
@ -130,19 +131,19 @@ func (b *UnimplementedWebCoreBinding) BindLogin(c *gin.Context) (*LoginReq, erro
|
|
|
|
|
|
|
|
|
|
|
|
func (b *UnimplementedWebCoreBinding) mustEmbedUnimplementedWebCoreBinding() {}
|
|
|
|
func (b *UnimplementedWebCoreBinding) mustEmbedUnimplementedWebCoreBinding() {}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *UnimplementedWebCoreRender) RenderIndex(c *gin.Context, err error) {
|
|
|
|
func (r *UnimplementedWebCoreRender) RenderIndex(c *gin.Context, err mir.Error) {
|
|
|
|
r.RenderAny(c, nil, err)
|
|
|
|
r.RenderAny(c, nil, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *UnimplementedWebCoreRender) RenderArticles(c *gin.Context, err error) {
|
|
|
|
func (r *UnimplementedWebCoreRender) RenderArticles(c *gin.Context, err mir.Error) {
|
|
|
|
r.RenderAny(c, nil, err)
|
|
|
|
r.RenderAny(c, nil, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *UnimplementedWebCoreRender) RenderLogin(c *gin.Context, data *LoginResp, err error) {
|
|
|
|
func (r *UnimplementedWebCoreRender) RenderLogin(c *gin.Context, data *LoginResp, err mir.Error) {
|
|
|
|
r.RenderAny(c, data, err)
|
|
|
|
r.RenderAny(c, data, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *UnimplementedWebCoreRender) RenderLogout(c *gin.Context, err error) {
|
|
|
|
func (r *UnimplementedWebCoreRender) RenderLogout(c *gin.Context, err mir.Error) {
|
|
|
|
r.RenderAny(c, nil, err)
|
|
|
|
r.RenderAny(c, nil, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|