openbrain/routers/filter.go

30 lines
536 B
Go
Raw Permalink Normal View History

2022-03-31 11:47:07 +08:00
package routers
import (
"net/http"
"strings"
"github.com/astaxie/beego/context"
2022-04-16 20:53:36 +08:00
"github.com/openbrainorg/openbrain/util"
2022-03-31 11:47:07 +08:00
)
func TransparentStatic(ctx *context.Context) {
urlPath := ctx.Request.URL.Path
if strings.HasPrefix(urlPath, "/api/") {
return
}
path := "web/build"
if urlPath == "/" {
path += "/index.html"
} else {
path += urlPath
}
if util.FileExist(path) {
http.ServeFile(ctx.ResponseWriter, ctx.Request, path)
} else {
http.ServeFile(ctx.ResponseWriter, ctx.Request, "web/build/index.html")
}
}