feat: window screenshot (PrintWindow), name-based window resolution
This commit is contained in:
parent
27b1ffc55b
commit
efc9cab2c3
6 changed files with 164 additions and 10 deletions
|
|
@ -114,6 +114,27 @@ pub async fn list_sessions(State(state): State<AppState>) -> Json<serde_json::Va
|
|||
Json(serde_json::json!({ "sessions": sessions }))
|
||||
}
|
||||
|
||||
/// POST /sessions/:id/windows/:window_id/screenshot
|
||||
pub async fn window_screenshot(
|
||||
Path((session_id, window_id)): Path<(String, u64)>,
|
||||
State(state): State<AppState>,
|
||||
) -> impl IntoResponse {
|
||||
match dispatch(&state, &session_id, "window_screenshot", |rid| {
|
||||
ServerMessage::WindowScreenshotRequest { request_id: rid, window_id }
|
||||
}).await {
|
||||
Ok(ClientMessage::ScreenshotResponse { image_base64, width, height, .. }) => (
|
||||
StatusCode::OK,
|
||||
Json(serde_json::json!({ "image_base64": image_base64, "width": width, "height": height })),
|
||||
).into_response(),
|
||||
Ok(ClientMessage::Error { message, .. }) => (
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(serde_json::json!({ "error": message })),
|
||||
).into_response(),
|
||||
Ok(_) => (StatusCode::BAD_GATEWAY, Json(serde_json::json!({ "error": "Unexpected response" }))).into_response(),
|
||||
Err(e) => e.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
/// POST /sessions/:id/screenshot
|
||||
pub async fn request_screenshot(
|
||||
Path(session_id): Path<String>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue