pub fn sign_request(
method: &str,
url: &str,
body: Option<&[u8]>,
key_id: &str,
key: &SigningKey<'_>,
now: i64,
) -> Result<SignedHeaders, Error>Expand description
Sign an outgoing request.
Covers @method and @target-uri, plus content-digest when there is a
body — the components Mastodon covers, so that a Mastodon peer verifies
what it expects to. The algorithm follows from the key.
§Arguments
method– HTTP method; canonicalised to uppercase for@methodurl– full request URL, which becomes@target-uribody– request body, orNonefor a bodyless requestkey_id–keyidparameter, the URI identifying the keykey– the private key to sign withnow– the time, in seconds since the Unix epoch, which becomescreated
§Errors
Returns an error if the key cannot be parsed or the signature cannot be made.