@@ -39,7 +39,7 @@ use warp::{
39
39
40
40
use crate :: {
41
41
dashboard:: Dashboard ,
42
- data:: { get_runner_data_path, run_migrations} ,
42
+ data:: { get_profile_data_path , get_runner_data_path, run_migrations} ,
43
43
github:: { list_registered_runners_for_host, Cache } ,
44
44
id:: IdGen ,
45
45
libvirt:: list_runner_guests,
@@ -69,6 +69,7 @@ static PNG: &str = "image/png";
69
69
/// - GET `/` => templates/index.html
70
70
/// - GET `/dashboard.html` => templates/dashboard.html
71
71
/// - GET `/dashboard.json` => `{"profile_runner_counts": {}, "runners": []}`
72
+ /// - GET `/profile/<profile key>/screenshot.png` => image/png
72
73
/// - GET `/runner/<our runner id>/screenshot.png` => image/png
73
74
#[ derive( Debug ) ]
74
75
enum Request {
@@ -229,7 +230,20 @@ async fn main() -> eyre::Result<()> {
229
230
} )
230
231
. with ( header ( "Content-Type" , JSON ) ) ;
231
232
232
- let screenshot_route = warp:: path!( "runner" / usize / "screenshot.png" )
233
+ let profile_screenshot_route = warp:: path!( "profile" / String / "screenshot.png" )
234
+ . and ( warp:: filters:: method:: get ( ) )
235
+ . and ( warp:: filters:: header:: optional ( "If-None-Match" ) )
236
+ . and_then (
237
+ |profile_key : String , if_none_match : Option < String > | async move {
238
+ let path = get_profile_data_path ( & profile_key, Path :: new ( "screenshot.png" ) )
239
+ . wrap_err ( "Failed to compute path" )
240
+ . map_err ( InternalError ) ?;
241
+ serve_static_file ( path, if_none_match)
242
+ } ,
243
+ )
244
+ . with ( header ( "Content-Type" , PNG ) ) ;
245
+
246
+ let runner_screenshot_route = warp:: path!( "runner" / usize / "screenshot.png" )
233
247
. and ( warp:: filters:: method:: get ( ) )
234
248
. and ( warp:: filters:: header:: optional ( "If-None-Match" ) )
235
249
. and_then ( |runner_id, if_none_match : Option < String > | async move {
@@ -240,7 +254,7 @@ async fn main() -> eyre::Result<()> {
240
254
} )
241
255
. with ( header ( "Content-Type" , PNG ) ) ;
242
256
243
- let screenshot_now_route = warp:: path!( "runner" / usize / "screenshot" / "now" )
257
+ let runner_screenshot_now_route = warp:: path!( "runner" / usize / "screenshot" / "now" )
244
258
. and ( warp:: filters:: method:: get ( ) )
245
259
. and_then ( |runner_id| async move {
246
260
|| -> eyre:: Result < Vec < u8 > > {
@@ -267,8 +281,9 @@ async fn main() -> eyre::Result<()> {
267
281
. or ( dashboard_html_route)
268
282
. or ( dashboard_json_route)
269
283
. or ( take_runner_route)
270
- . or ( screenshot_route)
271
- . or ( screenshot_now_route) ;
284
+ . or ( profile_screenshot_route)
285
+ . or ( runner_screenshot_route)
286
+ . or ( runner_screenshot_now_route) ;
272
287
let routes = routes. recover ( recover) ;
273
288
274
289
warp:: serve ( routes)
0 commit comments