Skip to content

Commit 39db3b1

Browse files
committed
cached rustlangredirector
1 parent 644ae50 commit 39db3b1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/config.rs

-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ pub struct Config {
3838
// Time between 'git gc --auto' calls in seconds
3939
pub(crate) registry_gc_interval: u64,
4040

41-
<<<<<<< HEAD
4241
// random crate search generates a number of random IDs to
4342
// efficiently find a random crate with > 100 GH stars.
4443
// The amount depends on the ratio of crates with >100 stars
@@ -47,10 +46,8 @@ pub struct Config {
4746
// `500` for a ratio of 7249 over 54k crates.
4847
// For unit-tests the number has to be higher.
4948
pub(crate) random_crate_search_view_size: u32,
50-
=======
5149
// CDN / caching settings
5250
pub(crate) cache_rustdoc_redirects: u32,
53-
>>>>>>> 53d35de (Set CDN caching headers for rustdoc redirects)
5451

5552
// Build params
5653
pub(crate) build_attempts: u16,

src/web/rustdoc.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::{
1212
use iron::url::percent_encoding::percent_decode;
1313
use iron::{
1414
headers::{CacheControl, CacheDirective, Expires, HttpDate},
15-
modifiers::Redirect,
1615
status, Handler, IronResult, Request, Response, Url,
1716
};
1817
use lol_html::errors::RewritingError;
@@ -37,8 +36,12 @@ impl RustLangRedirector {
3736
}
3837

3938
impl iron::Handler for RustLangRedirector {
40-
fn handle(&self, _req: &mut Request) -> IronResult<Response> {
41-
Ok(Response::with((status::Found, Redirect(self.url.clone()))))
39+
fn handle(&self, req: &mut Request) -> IronResult<Response> {
40+
let config = extension!(req, Config);
41+
Ok(super::cached_redirect(
42+
self.url.clone(),
43+
config.cache_rustdoc_redirects,
44+
))
4245
}
4346
}
4447

0 commit comments

Comments
 (0)