diff --git a/plugin/src/ApiContext.lua b/plugin/src/ApiContext.lua index 018f9072b..19f46ac12 100644 --- a/plugin/src/ApiContext.lua +++ b/plugin/src/ApiContext.lua @@ -240,7 +240,7 @@ function ApiContext:open(id) end function ApiContext:fetch(ids: { string }) - local url = ("%s/api/fetch/%s"):format(self.__baseUrl, table.concat(ids, ",")) + local url = ("%s/api/fetch"):format(self.__baseUrl) local requestBody = { sessionId = self.__sessionId, idList = ids, diff --git a/src/web/api.rs b/src/web/api.rs index c7e57c913..0129bb064 100644 --- a/src/web/api.rs +++ b/src/web/api.rs @@ -45,9 +45,7 @@ pub async fn call(serve_session: Arc, request: Request) -> R (&Method::POST, "/api/write") => service.handle_api_write(request).await, - (&Method::POST, path) if path.starts_with("/api/fetch/") => { - service.handle_api_fetch_get(request).await - } + (&Method::POST, "/api/fetch") => service.handle_api_fetch_post(request).await, (_method, path) => json( ErrorResponse::not_found(format!("Route not found: {}", path)), @@ -288,7 +286,7 @@ impl ApiService { }) } - async fn handle_api_fetch_get(&self, request: Request) -> Response { + async fn handle_api_fetch_post(&self, request: Request) -> Response { let body = body::to_bytes(request.into_body()).await.unwrap(); let request: FetchRequest = match serde_json::from_slice(&body) { diff --git a/src/web/interface.rs b/src/web/interface.rs index 893ce1b43..8c6ad1892 100644 --- a/src/web/interface.rs +++ b/src/web/interface.rs @@ -204,6 +204,7 @@ pub struct OpenResponse { pub session_id: SessionId, } +/// A request POSTed to /api/fetch #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct FetchRequest { @@ -211,7 +212,7 @@ pub struct FetchRequest { pub id_list: Vec, } -/// Response body from GET /api/fetch/{ids} +/// Response body from POST /api/fetch #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct FetchResponse<'a> {