Skip to content

Conversation

@pawbana
Copy link
Contributor

@pawbana pawbana commented Jan 29, 2026

When requst is being passed though the change makes it so paht of the forwarded request incudles path of configured base url.

Example:

providers base url: http://some.domain/some/path

pass though route: /route

url of passed though request before: http://some.domain/route

after the change: http://some.domain/some/path/route

Copy link
Contributor Author

pawbana commented Jan 29, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@pawbana pawbana marked this pull request as ready for review January 29, 2026 18:21
@pawbana pawbana requested a review from dannykopping January 29, 2026 18:23
@pawbana pawbana force-pushed the pb/base_url_with_path branch 3 times, most recently from a4b4177 to cd873b1 Compare January 29, 2026 21:04
@pawbana pawbana force-pushed the pb/base_url_with_path branch from cd873b1 to 41548c5 Compare January 29, 2026 21:29
@pawbana pawbana changed the title fix: add base url path as a prefix to bridged and pass through routes fix: add base url path as a prefix to pass through routes Jan 30, 2026
@pawbana pawbana changed the title fix: add base url path as a prefix to pass through routes feat: add path of providers base url to pass though requests Jan 30, 2026
@pawbana pawbana changed the title feat: add path of providers base url to pass though requests feat: add path of providers base url to pass through requests Jan 30, 2026
req.URL.Path, err = url.JoinPath(upURL.Path, r.URL.Path)
if err != nil {
logger.Warn(ctx, "failed to join upstream path", slog.Error(err), slog.F("upstreamPath", upURL.Path), slog.F("requestPath", req.URL.Path))
req.URL.Path = r.URL.Path // Fallback to just the request path.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fail loud and proud.
If we can't join then we should just fail the request rather then it routing unpredictably.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch is also lacking test coverage.

}

func newMockServer(ctx context.Context, t *testing.T, files archiveFileMap, responseMutatorFn func(reqCount uint32, resp []byte) []byte) *mockServer {
func newMockServer(ctx context.Context, t *testing.T, files archiveFileMap, requestValidatorFn func(*http.Request), responseMutatorFn func(reqCount uint32, resp []byte) []byte) *mockServer {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For later: we should refactor this to take a variadic set of options.

@@ -44,11 +44,15 @@ func newPassthroughRouter(provider provider.Provider, logger slog.Logger, m *met
req.URL.Host = upURL.Host

// Preserve the stripped path from the incoming request and ensure leading slash.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't match the implementation anymore.

func TestSimple(t *testing.T) {
t.Parallel()

getAnthropicResponseID := func(streaming bool, resp *http.Response) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: let's move these into helper funcs; they're probably reusable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be done in: #73

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants