Define RequestTarget

This commit is contained in:
Kitaiti Makoto 2021-01-25 00:13:53 +09:00
parent bd1caaf5da
commit 191239584b
2 changed files with 4 additions and 4 deletions

View File

@ -164,7 +164,7 @@ where
.headers(headers.clone())
.header(
"Signature",
request::signature(sender, &headers, "post", url.path(), url.query())
request::signature(sender, &headers, ("post", url.path(), url.query()))
.expect("activity_pub::broadcast: request signature error"),
)
.body(body)

View File

@ -115,14 +115,14 @@ pub fn headers() -> HeaderMap {
type Method<'a> = &'a str;
type Path<'a> = &'a str;
type Query<'a> = &'a str;
type RequestTarget<'a> = (Method<'a>, Path<'a>, Option<Query<'a>>);
pub fn signature<S: Signer>(
signer: &S,
headers: &HeaderMap,
method: Method,
path: Path,
query: Option<Query>,
request_target: RequestTarget,
) -> Result<HeaderValue, Error> {
let (method, path, query) = request_target;
let origin_form = if let Some(query) = query {
format!("{}?{}", path, query)
} else {