feat:完善信息

This commit is contained in:
henry
2022-01-25 11:45:53 +08:00
parent 26b58e3ca6
commit 932ed31450
13 changed files with 169 additions and 45 deletions

View File

@ -3,11 +3,13 @@ package router
import (
"SciencesServer/config"
"SciencesServer/router/rate"
"github.com/prometheus/client_golang/prometheus/promhttp"
"io"
"net/http"
"os"
"time"
"github.com/chenjiandongx/ginprom"
"github.com/gin-gonic/gin"
)
@ -37,18 +39,14 @@ func (this *Router) Init() *gin.Engine {
if this.IsCors {
app.Use(Cors())
}
//app.LoadHTMLFiles("./dist/*") // 添加资源路径
app.LoadHTMLGlob("./dist/index.html") // 添加资源路径
app.StaticFS("/static", http.Dir("./dist/static"))
app.GET("", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", nil)
})
//app.NoRoute(NoRouteHandler())
app.NoRoute(NoRouteHandler())
app.NoMethod(NoMethodHandler())
app.Use(ginprom.PromMiddleware(nil))
app.Use(LoggerHandle("log/gin.log", 3))
app.Use(TimeoutHandle(time.Second * 30))
//app.Use(RecoveryHandler())
app.Use(RecoveryHandler())
app.GET("/metrics", ginprom.PromHandler(promhttp.Handler()))
if this.RateLimitConfig != nil {
if this.RateLimitConfig.IsRate {