mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-07-08 01:32:41 +08:00
Remove unwrap in filter_http_methods macro
This commit is contained in:
@@ -12,6 +12,7 @@ pub enum PixivDownloaderError {
|
||||
UgoiraError(UgoiraError),
|
||||
#[cfg(feature = "server")]
|
||||
Hyper(hyper::Error),
|
||||
HTTP(http::Error),
|
||||
}
|
||||
|
||||
impl From<&str> for PixivDownloaderError {
|
||||
@@ -20,6 +21,12 @@ impl From<&str> for PixivDownloaderError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<http::header::InvalidHeaderValue> for PixivDownloaderError {
|
||||
fn from(v: http::header::InvalidHeaderValue) -> Self {
|
||||
Self::HTTP(http::Error::from(v))
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! concat_pixiv_downloader_error {
|
||||
($exp1:expr, $exp2:expr) => {
|
||||
|
||||
@@ -28,9 +28,7 @@ impl ResponseJsonFor<Body> for VersionContext {
|
||||
req: Request<Body>,
|
||||
) -> Result<Response<JsonValue>, PixivDownloaderError> {
|
||||
filter_http_methods!(req, json::object! {}, true, self.ctx, GET, OPTIONS, POST);
|
||||
Ok(builder
|
||||
.body(json::object! {"version": [0, 0, 1, 0]})
|
||||
.unwrap())
|
||||
Ok(builder.body(json::object! {"version": [0, 0, 1, 0]})?)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user