mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-23 05:08:13 -05:00
37 lines
629 B
Go
37 lines
629 B
Go
package mygin
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/naiba/nezha/model"
|
|
"github.com/naiba/nezha/service/singleton"
|
|
)
|
|
|
|
type ErrInfo struct {
|
|
Code int
|
|
Title string
|
|
Msg string
|
|
Link string
|
|
Btn string
|
|
}
|
|
|
|
func ShowErrorPage(c *gin.Context, i ErrInfo, isPage bool) {
|
|
if isPage {
|
|
c.HTML(i.Code, "dashboard-"+singleton.Conf.Site.DashboardTheme+"/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()
|
|
}
|