-
Notifications
You must be signed in to change notification settings - Fork 1
Updated for redirects and skipping unmarshalling #53
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -15,11 +15,9 @@ import ( | |||
| "time" | ||||
|
|
||||
| // Package imports | ||||
| pkgotel "github.com/mutablelogic/go-client/pkg/otel" | ||||
| otel "github.com/mutablelogic/go-client/pkg/otel" | ||||
| httpresponse "github.com/mutablelogic/go-server/pkg/httpresponse" | ||||
|
||||
| httpresponse "github.com/mutablelogic/go-server/pkg/httpresponse" |
djthorpe marked this conversation as resolved.
Show resolved
Hide resolved
djthorpe marked this conversation as resolved.
Show resolved
Hide resolved
djthorpe marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Jan 25, 2026
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 manual redirect handling logic will never execute because the HTTP client doesn't have CheckRedirect set to disable automatic redirects. The default Go HTTP client automatically follows up to 10 redirects. To make this manual redirect logic work, the client initialization in New() needs to set CheckRedirect to return http.ErrUseLastResponse to prevent automatic redirect following.
Copilot
AI
Jan 25, 2026
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.
Using http.StatusNotAcceptable (406) for client-side validation errors may be misleading. The actual HTTP response was successful (2xx), but the error suggests the server returned a 406 status. Consider using a different error type that doesn't imply an HTTP status code from the server, such as a custom validation error or ErrBadRequest, to avoid confusion.
Copilot
AI
Jan 25, 2026
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.
If the Unmarshaler reads from the response.Body before returning ErrNotImplemented, the body will be partially or fully consumed, and the fallback to default unmarshaling will fail. Consider documenting that Unmarshaler implementations must return ErrNotImplemented without reading from the body if they want to fall back to default unmarshaling, or use a buffer/seeker to allow re-reading the body.
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.
The NewJSONRequest function signature is
NewJSONRequest(payload any) (Payload, error)and takes only one parameter. The second parameterclient.ContentTypeJsonshould be removed. If you need to specify the accept type, useNewJSONRequestEx(http.MethodPost, request, client.ContentTypeJson)instead.