You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

filter.go 527 B

1234567891011121314151617181920212223242526272829
  1. package routers
  2. import (
  3. "net/http"
  4. "strings"
  5. "github.com/beego/beego/context"
  6. "github.com/casbin/casvisor/util"
  7. )
  8. func TransparentStatic(ctx *context.Context) {
  9. urlPath := ctx.Request.URL.Path
  10. if strings.HasPrefix(urlPath, "/api/") {
  11. return
  12. }
  13. path := "web/build"
  14. if urlPath == "/" {
  15. path += "/index.html"
  16. } else {
  17. path += urlPath
  18. }
  19. if util.FileExist(path) {
  20. http.ServeFile(ctx.ResponseWriter, ctx.Request, path)
  21. } else {
  22. http.ServeFile(ctx.ResponseWriter, ctx.Request, "web/build/index.html")
  23. }
  24. }