Add func for easy double-knocking of requests
This commit is contained in:
parent
6cc699cbbd
commit
ef58b5ca9b
1 changed files with 19 additions and 0 deletions
|
@ -29,6 +29,25 @@ Links for home:
|
|||
- https://datatracker.ietf.org/doc/html/rfc9421
|
||||
*/
|
||||
|
||||
// Perform a signed request. Tries RFC9421 first and on fail cavage.
|
||||
// This double-knocking is because implementations currently use cavage (a precursor to RFC9421).
|
||||
// However, Cavage is deprecated now and the RFC should be used instead. And so
|
||||
// implementations have slowly begun to implement the RFC in addition to cavage
|
||||
//
|
||||
// Returns the unmodified response, if the request completed with RFC signing and an error, if any
|
||||
func RequestSigned(
|
||||
method, target string,
|
||||
body []byte,
|
||||
actor *models.User,
|
||||
) (response *http.Response, wasRfc9421 bool, err error) {
|
||||
res, err := RequestSignedRFC9421(method, target, body, actor)
|
||||
if err == nil {
|
||||
return res, true, nil
|
||||
}
|
||||
res, err = RequestSignedCavage(method, target, body, actor)
|
||||
return res, false, err
|
||||
}
|
||||
|
||||
// Perform a request, signing it as specified in RFC 9421
|
||||
func RequestSignedRFC9421(
|
||||
method, target string,
|
||||
|
|
Loading…
Reference in a new issue