Skip to content

Commit

Permalink
Fix Request struct.
Browse files Browse the repository at this point in the history
  • Loading branch information
BartVerc committed Jul 12, 2021
1 parent 854d784 commit 545a7b6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugin:
Request:
```json
{
"url": "https://rout-to-app.domain.com/volume1"
"request": "https://route-to-app.domain.com/volume1"
}
```

Expand Down
4 changes: 1 addition & 3 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (a *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
log.Println(fmt.Sprintf("Resolving header for %s", req.URL))

requestBody, err := json.Marshal(map[string]string{
"url": fmt.Sprintf("%s", req.URL),
"request": fmt.Sprintf("%s", req.URL),
})
if err != nil {
log.Println("Requestbody marshalling error.")
Expand Down Expand Up @@ -146,9 +146,7 @@ func (a *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
continue
}

fmt.Println(rewrite.Template)
t := addDollarSigns(rewrite.Template)
fmt.Println(string(t))

if check.Match([]byte(req.URL.Path)) {
newpath := check.ReplaceAll([]byte(req.URL.Path), t)
Expand Down
4 changes: 2 additions & 2 deletions router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

type UrlResponse struct {
Url string `json:"url,omitempty"`
Request string `json:"request,omitempty"`
}

func TestRouter(t *testing.T) {
Expand Down Expand Up @@ -105,7 +105,7 @@ func TestRouter(t *testing.T) {
body, _ := ioutil.ReadAll(r.Body)
urlresponse := &UrlResponse{}
_ = json.Unmarshal(body, urlresponse)
u, _:= url.Parse(urlresponse.Url)
u, _:= url.Parse(urlresponse.Request)
if u.Path == "/test1" {
w.Write(body1)
} else if u.Path == "/test2/path/rewritepart/bla" {
Expand Down

0 comments on commit 545a7b6

Please sign in to comment.