Skip to content

Commit

Permalink
fix(pkg/server): Better target construction
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejsika committed Apr 22, 2024
1 parent 67f88ac commit 850c0f6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"net/http"
)

func Server(target string, preservePath bool) error {
func Server(baseTarget string, preservePath bool) error {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
target := baseTarget
if preservePath {
target = fmt.Sprintf("%s%s", target, r.URL.Path)
target = fmt.Sprintf("%s%s", baseTarget, r.URL.Path)
}
http.Redirect(w, r, target, http.StatusTemporaryRedirect)
})
Expand Down

0 comments on commit 850c0f6

Please sign in to comment.