Tweak federation client proxying

This commit is contained in:
Neil Alexander 2022-08-11 11:18:48 +01:00
parent b099e7cb75
commit 11802a007e
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 4 additions and 5 deletions

View file

@ -221,11 +221,10 @@ func AddRoutes(intAPI api.FederationInternalAPI, internalAPIMux *mux.Router) {
)
}
func federationClientError(err error) *api.FederationClientError {
if err == nil {
return nil
}
func federationClientError(err error) error {
switch ferr := err.(type) {
case nil:
return nil
case api.FederationClientError:
return &ferr
case *api.FederationClientError:

View file

@ -78,7 +78,7 @@ func PostJSON[reqtype, restype any, errtype error](
}
if res.StatusCode != http.StatusOK {
if len(body) == 0 {
return fmt.Errorf("HTTP %d from %s", res.StatusCode, apiURL)
return fmt.Errorf("HTTP %d from %s (no response body)", res.StatusCode, apiURL)
}
var reserr errtype
if err = json.Unmarshal(body, reserr); err != nil {