Skip to content

Commit

Permalink
Support file path
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeguy committed Oct 8, 2023
1 parent c476981 commit 1469454
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions service/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/http"
"net/http/httputil"
"net/url"
"path/filepath"
"strings"

"github.com/beego/beego"
Expand Down Expand Up @@ -138,8 +139,19 @@ func handleRequest(w http.ResponseWriter, r *http.Request) {
}
}

targetUrl := joinPath(site.GetHost(), r.RequestURI)
forwardHandler(targetUrl, w, r)
host := site.GetHost()
if host == "" {
responseError(w, "CasWAF error: targetUrl should not be empty for host: %s, site = %v", r.Host, site)
return
}

if strings.HasPrefix(host, "http") {
targetUrl := joinPath(site.GetHost(), r.RequestURI)
forwardHandler(targetUrl, w, r)
} else {
path := filepath.Join(host, r.RequestURI)
http.ServeFile(w, r, path)
}
}

func Start() {
Expand Down

0 comments on commit 1469454

Please sign in to comment.