Adding rewrite option to proxy service#204
Merged
Roasbeef merged 4 commits intolightninglabs:masterfrom Mar 24, 2026
Merged
Conversation
1ed3f17 to
f768e6d
Compare
Contributor
Author
Collaborator
|
Hi @sergey3bv, thanks for your contribution. There are no tests for either the validation logic in prepareServices() or the rewrite behavior in director(). The existing proxy_test.go doesn't test the director at all. At minimum, tests should cover:
|
f768e6d to
eaf906d
Compare
eaf906d to
14344b2
Compare
Contributor
Author
|
@hieblmi, I added tests. What do you think? |
14344b2 to
6134ab2
Compare
Collaborator
|
Hi @sergey3bv, nice work. there still seems to be a bug in proxy/proxy.go:95 — when rewriteRequestPath sets req.URL.Path, it doesn't clear req.URL.RawPath. Also can we add the two missing test categories
|
6134ab2 to
d3bbbdb
Compare
Contributor
Author
|
@hieblmi, everything is good on my side, do I need to update anything else? |
Contributor
Author
hieblmi
approved these changes
Mar 24, 2026
Collaborator
hieblmi
left a comment
There was a problem hiding this comment.
Thanks again for your changes. LGTM!
Address review findings for the rewrite prefix feature: - Use url.URL.JoinPath instead of url.JoinPath to correctly preserve percent-encoded characters (e.g., %2F) in RawPath. Backends that rely on RawPath for routing (gRPC-gateway, etc.) will now see the original encoding rather than a blanket-cleared RawPath. - Consolidate error messages in prepareRewrite to use "invalid prefix format" consistently for both parse and semantic errors. Fix trailing space in the error format string, use %q for quoting. - Store validated prefix via u.Path instead of u.EscapedPath() to avoid redundant double-normalization in the hot path. - Comment out sample-conf.yaml headers/rewrite blocks with placeholder credential to prevent users from copying a Bearer token verbatim. - Document known limitation: backend redirect Location headers are not rewritten to strip the prefix. - Expand test coverage with edge cases: root path (/), identity prefix (/), double slashes, dot segments, encoded spaces, deeply nested prefixes, and RawPath preservation verification.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addressing #157