support static files

This commit is contained in:
710leo 2021-04-15 21:23:59 +08:00
parent 46f7ec7af9
commit 3f0dfd63d4
4 changed files with 7 additions and 1 deletions

1
go.mod
View File

@ -12,6 +12,7 @@ require (
github.com/gaochao1/sw v4.0.0+incompatible
github.com/garyburd/redigo v1.6.2
github.com/gin-contrib/pprof v1.3.0
github.com/gin-contrib/static v0.0.1
github.com/gin-gonic/gin v1.6.3
github.com/go-ping/ping v0.0.0-20201115131931-3300c582a663
github.com/go-sql-driver/mysql v1.5.0

2
go.sum
View File

@ -284,6 +284,8 @@ github.com/gin-contrib/pprof v1.3.0 h1:G9eK6HnbkSqDZBYbzG4wrjCsA4e+cvYAHUZw6W+W9
github.com/gin-contrib/pprof v1.3.0/go.mod h1:waMjT1H9b179t3CxuG1cV3DHpga6ybizwfBaM5OXaB0=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-contrib/static v0.0.1 h1:JVxuvHPuUfkoul12N7dtQw7KRn/pSMq7Ue1Va9Swm1U=
github.com/gin-contrib/static v0.0.1/go.mod h1:CSxeF+wep05e0kCOsqWdAWbSszmc31zTIbD8TvWl7Hs=
github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=

View File

@ -89,7 +89,7 @@ func (r *Role) Save(ops []string) error {
session := DB["rdb"].NewSession()
defer session.Close()
cnt, err := session.Where("name=?", r.Name).Count(new(Role))
cnt, err := session.Where("name=? and cate=?", r.Name, r.Cate).Count(new(Role))
if err != nil {
return err
}

View File

@ -8,6 +8,7 @@ import (
"strings"
"time"
"github.com/gin-contrib/static"
"github.com/gin-gonic/gin"
"github.com/didi/nightingale/v4/src/common/address"
@ -41,6 +42,8 @@ func Start() {
r.Use(loggerMid)
}
r.Use(static.Serve("/", static.LocalFile("./pub", false)))
Config(r)
initStats()