mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-06 05:30:05 +00:00
Web 服务
This commit is contained in:
37
pkg/mygin/error.go
Normal file
37
pkg/mygin/error.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package mygin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/p14yground/nezha/model"
|
||||
)
|
||||
|
||||
// ErrInfo ..
|
||||
type ErrInfo struct {
|
||||
Code uint64
|
||||
Title string
|
||||
Msg string
|
||||
Link string
|
||||
Btn string
|
||||
}
|
||||
|
||||
// ShowErrorPage ..
|
||||
func ShowErrorPage(c *gin.Context, i ErrInfo, isPage bool) {
|
||||
if isPage {
|
||||
c.HTML(http.StatusOK, "page/error", CommonEnvironment(c, gin.H{
|
||||
"Code": i.Code,
|
||||
"Title": i.Title,
|
||||
"Msg": i.Msg,
|
||||
"Link": i.Link,
|
||||
"Btn": i.Btn,
|
||||
}))
|
||||
} else {
|
||||
c.JSON(http.StatusOK, model.Response{
|
||||
Code: i.Code,
|
||||
Message: i.Msg,
|
||||
})
|
||||
}
|
||||
c.Abort()
|
||||
}
|
||||
Reference in New Issue
Block a user