Add new options allow_headers for filter_http_methods

This commit is contained in:
2022-07-10 01:25:18 +00:00
committed by GitHub
parent 2f2a5c0eb1
commit bbd6a8d694
2 changed files with 62 additions and 5 deletions

View File

@@ -27,7 +27,16 @@ impl ResponseJsonFor<Body> for VersionContext {
&self,
req: Request<Body>,
) -> Result<Response<JsonValue>, PixivDownloaderError> {
filter_http_methods!(req, json::object! {}, true, self.ctx, GET, OPTIONS, POST);
filter_http_methods!(
req,
json::object! {},
true,
self.ctx,
allow_headers = [X_TOKEN],
GET,
OPTIONS,
POST
);
Ok(builder.body(json::object! {"version": [0, 0, 1, 0]})?)
}
}
@@ -39,7 +48,7 @@ pub struct VersionRoute {
impl VersionRoute {
pub fn new() -> Self {
Self {
regex: Regex::new(r"^(/api)?/version(/.*)?$").unwrap(),
regex: Regex::new(r"^(/+api)?/+version(/.*)?$").unwrap(),
}
}
}