mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-14 05:12:26 +03:00
gb vendor update github.com/matrix-org/gomatrixserverlib
This commit is contained in:
parent
847621bc5d
commit
b7687310fe
3 changed files with 27 additions and 3 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"net/url"
|
||||
|
||||
"github.com/matrix-org/gomatrix"
|
||||
"github.com/matrix-org/util"
|
||||
"golang.org/x/crypto/ed25519"
|
||||
)
|
||||
|
||||
|
@ -33,6 +34,9 @@ func NewFederationClient(
|
|||
}
|
||||
|
||||
func (ac *FederationClient) doRequest(ctx context.Context, r FederationRequest, resBody interface{}) error {
|
||||
reqID := util.RandomString(12)
|
||||
logger := util.GetLogger(ctx).WithField("server", r.fields.Destination).WithField("out.req.ID", reqID)
|
||||
|
||||
if err := r.Sign(ac.serverName, ac.serverKeyID, ac.serverPrivateKey); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -42,16 +46,21 @@ func (ac *FederationClient) doRequest(ctx context.Context, r FederationRequest,
|
|||
return err
|
||||
}
|
||||
|
||||
logger.Infof("Outgoing request %s %s", req.Method, req.URL)
|
||||
res, err := ac.client.Do(req.WithContext(ctx))
|
||||
if res != nil {
|
||||
defer res.Body.Close() // nolint: errcheck
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
logger.Infof("Outgoing request %s %s failed with %v", req.Method, req.URL, err)
|
||||
return err
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadAll(res.Body)
|
||||
|
||||
logger.Infof("Response %d from %s %s", res.StatusCode, req.Method, req.URL)
|
||||
|
||||
if res.StatusCode/100 != 2 { // not 2xx
|
||||
// Adapted from https://github.com/matrix-org/gomatrix/blob/master/client.go
|
||||
var wrap error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue