fixed path

This commit is contained in:
regnaio 2022-03-29 07:33:38 -04:00
parent 901fd63c97
commit 98a9571da9
1 changed files with 5 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"path"
"strconv"
"strings"
@ -81,10 +82,11 @@ func (p *Proxy) ProxyHTTP(
fmt.Println(fmt.Sprintf("before: req.URL.Path: %s", req.URL.Path))
parts := strings.Split(req.URL.Path, "/")
if len(parts) > 0 {
parts[0] = rule.Location
fmt.Println("parts:", parts)
if len(parts) > 1 {
parts[1] = rule.Location
}
req.URL.Path = strings.Join(parts, "/")
req.URL.Path = path.Clean(strings.Join(parts, "/"))
fmt.Println(fmt.Sprintf("after: req.URL.Path: %s", req.URL.Path))
switch originProxy := rule.Service.(type) {