-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add path of providers base url to pass through requests #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
a4b4177 to
cd873b1
Compare
cd873b1 to
41548c5
Compare
| 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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. | |||
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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

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/pathpass though route:
/routeurl of passed though request before:
http://some.domain/routeafter the change:
http://some.domain/some/path/route