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