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.
64 lines
1.5 KiB
64 lines
1.5 KiB
// Code generated by go-mir. DO NOT EDIT.
|
|
// versions:
|
|
// - mir v4.2.0
|
|
|
|
package v1
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/alimy/mir/v4"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/rocboss/paopao-ce/internal/conf"
|
|
"github.com/rocboss/paopao-ce/internal/model/web"
|
|
)
|
|
|
|
type Site interface {
|
|
_default_
|
|
|
|
Profile() (*conf.WebProfileConf, mir.Error)
|
|
Version() (*web.VersionResp, mir.Error)
|
|
|
|
mustEmbedUnimplementedSiteServant()
|
|
}
|
|
|
|
// RegisterSiteServant register Site servant to gin
|
|
func RegisterSiteServant(e *gin.Engine, s Site) {
|
|
router := e.Group("v1")
|
|
|
|
// register routes info to router
|
|
router.Handle("GET", "/site/profile", func(c *gin.Context) {
|
|
select {
|
|
case <-c.Request.Context().Done():
|
|
return
|
|
default:
|
|
}
|
|
|
|
resp, err := s.Profile()
|
|
s.Render(c, resp, err)
|
|
})
|
|
router.Handle("GET", "/site/version", func(c *gin.Context) {
|
|
select {
|
|
case <-c.Request.Context().Done():
|
|
return
|
|
default:
|
|
}
|
|
|
|
resp, err := s.Version()
|
|
s.Render(c, resp, err)
|
|
})
|
|
}
|
|
|
|
// UnimplementedSiteServant can be embedded to have forward compatible implementations.
|
|
type UnimplementedSiteServant struct{}
|
|
|
|
func (UnimplementedSiteServant) Profile() (*conf.WebProfileConf, mir.Error) {
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
}
|
|
|
|
func (UnimplementedSiteServant) Version() (*web.VersionResp, mir.Error) {
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
}
|
|
|
|
func (UnimplementedSiteServant) mustEmbedUnimplementedSiteServant() {}
|