@@ -9,7 +9,7 @@ macro_rules! ctry {
9
9
( $result: expr) => ( match $result {
10
10
Ok ( v) => v,
11
11
Err ( e) => {
12
- return super :: page:: Page :: new( format!( "{:?}" , e) ) . title( "An error has occured" )
12
+ return $crate :: web :: page:: Page :: new( format!( "{:?}" , e) ) . title( "An error has occured" )
13
13
. set_status( :: iron:: status:: BadRequest ) . to_resp( "resp" ) ;
14
14
}
15
15
} )
@@ -21,7 +21,7 @@ macro_rules! cexpect {
21
21
( $option: expr) => ( match $option {
22
22
Some ( v) => v,
23
23
None => {
24
- return super :: page:: Page :: new( "Resource not found" . to_owned( ) )
24
+ return $crate :: web :: page:: Page :: new( "Resource not found" . to_owned( ) )
25
25
. title( "An error has occured" )
26
26
. set_status( :: iron:: status:: BadRequest ) . to_resp( "resp" ) ;
27
27
}
@@ -485,6 +485,25 @@ fn opensearch_xml_handler(_: &mut Request) -> IronResult<Response> {
485
485
Ok ( response)
486
486
}
487
487
488
+ fn ico_handler ( req : & mut Request ) -> IronResult < Response > {
489
+ use iron:: Url ;
490
+
491
+ if let Some ( & "favicon.ico" ) = req. url . path ( ) . last ( ) {
492
+ // if we're looking for exactly "favicon.ico", we need to defer to the handler that loads
493
+ // from `public_html`, so return a 404 here to make the main handler carry on
494
+ Err ( IronError :: new ( error:: Nope :: ResourceNotFound , status:: NotFound ) )
495
+ } else {
496
+ // if we're looking for something like "favicon-20190317-1.35.0-nightly-c82834e2b.ico",
497
+ // redirect to the plain one so that the above branch can trigger with the correct filename
498
+ let url = ctry ! ( Url :: parse( & format!( "{}://{}:{}/favicon.ico" ,
499
+ req. url. scheme( ) ,
500
+ req. url. host( ) ,
501
+ req. url. port( ) ) [ ..] ) ) ;
502
+
503
+ Ok ( redirect ( url) )
504
+ }
505
+ }
506
+
488
507
/// MetaData used in header
489
508
#[ derive( Debug ) ]
490
509
pub struct MetaData {
0 commit comments