Skip to content

Commit

Permalink
Merge pull request #714 from luraproject/minor_optimizations
Browse files Browse the repository at this point in the history
Minor optimizations
  • Loading branch information
kpacha authored Mar 7, 2024
2 parents 9249c56 + 6fd3a58 commit f836a87
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
6 changes: 1 addition & 5 deletions proxy/balancing.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package proxy
import (
"context"
"net/url"
"strings"

"github.com/luraproject/lura/v2/config"
"github.com/luraproject/lura/v2/logging"
Expand Down Expand Up @@ -97,10 +96,7 @@ func newLoadBalancedMiddleware(l logging.Logger, lb sd.Balancer) Middleware {
}
r := request.Clone()

var b strings.Builder
b.WriteString(host)
b.WriteString(r.Path)
r.URL, err = url.Parse(b.String())
r.URL, err = url.Parse(host + r.Path)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions proxy/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,10 @@ func newRequestBuilderMiddleware(l logging.Logger, remote *config.Backend) Middl
l.Fatal("too many proxies for this %s %s -> %s proxy middleware: newRequestBuilderMiddleware only accepts 1 proxy, got %d", remote.ParentEndpointMethod, remote.ParentEndpoint, remote.URLPattern, len(next))
return nil
}
return func(ctx context.Context, request *Request) (*Response, error) {
r := request.Clone()
return func(ctx context.Context, r *Request) (*Response, error) {
r.GeneratePath(remote.URLPattern)
r.Method = remote.Method
return next[0](ctx, &r)
return next[0](ctx, r)
}
}
}
Expand Down

0 comments on commit f836a87

Please sign in to comment.