This commit is contained in:
2022-07-08 04:43:29 +00:00
committed by GitHub
parent 23ca8010e0
commit 8542a68176
3 changed files with 53 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ impl Service<Request<Body>> for PixivDownloaderSvc {
}
fn call(&mut self, req: Request<Body>) -> Self::Future {
println!("{} {}", req.method(), req.uri());
match self.routes.match_route(&req) {
Some(route) => Box::pin(async move {
match route.response(req).await {

View File

@@ -6,6 +6,7 @@ use hyper::Body;
use hyper::Request;
use hyper::Response;
use json::JsonValue;
use proc_macros::filter_http_methods;
use regex::Regex;
pub struct VersionContext {
@@ -22,8 +23,9 @@ impl VersionContext {
impl ResponseJsonFor<Body> for VersionContext {
async fn response_json(
&self,
_req: Request<Body>,
req: Request<Body>,
) -> Result<Response<JsonValue>, PixivDownloaderError> {
filter_http_methods!(req, json::object! {}, GET, OPTIONS, POST);
Ok(Response::new(json::object! {"version": [0, 0, 1, 0]}))
}
}