-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: redirect static-router/doc/master to stable docs (#568) #571
base: master
Are you sure you want to change the base?
Conversation
terragrunt/modules/release-distribution/lambdas/static-router/index.js
Outdated
Show resolved
Hide resolved
I pushed a fix (the second argument of the https://cloudfront-dev-static.rust-lang.org/doc/master/rust.html works!
Here's the location: Do you want to look into that as well? |
Thank you for fixing the I've made a stab at the fastly VCL change. I didn't test it either, but hopefully it's correct. |
We should try to add a linter for that code honestly 😅 Thanks, I'll test this soon! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. If you need any help with Fastly, feel free to ping me. 🙂
snippet { | ||
# This was an abandoned copy of Rust 1.17.0-era docs; redirect to current docs | ||
name = "redirect /doc/master to /stable" | ||
type = "error" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The snippet will not be executed, since we never make it to the error
state in the VCL lifecycle. That's why the existing snippet that redirects rustup.sh
first has a snippet that detects requests to that endpoint and then fails them with a custom error that we're handling manually.
snippet {
name = "detect rustup.sh requests"
type = "recv"
content = <<-VCL
if (req.url ~ "^\/rustup\.sh$") {
error 618 "redirect";
}
VCL
}
We need something like this for the docs as well. I suggest that we use a new error code (e.g. 619
), and then replicate how rustup.sh
is handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added this new error in cdd0f7b
name = "redirect /doc/master to /stable" | ||
type = "error" | ||
content = <<-VCL | ||
if (req.url ~ "^\/doc/master(\/|$)")?$") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not counting wrong, there's a (
missing or a )
too many somewhere. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to simplify the regex in cdd0f7b
I think this is ready to be tested. What do you think JD? One concern I have is that previous links pointing to docs will now be empty. e.g. https://static.rust-lang.org/doc/master/reference.html#whitespace will now point to https://doc.rust-lang.org/stable/reference.html#whitespace, so people need to look for the info they were looking for again in the new docs. I think this is fine, since imo is better if people spend a few seconds more for their research but at least hey find up-to-date docs. Plus, the rust reference book has a search box 👍 EDIT: fastly tested here |
Testing
I didn't test this, I'm not sure how to do so.
Rationale for
stable
I decided that a redirect to
//doc.rust-lang.org/stable/*
makes the most sense. While thedoc-router
redirects/master
to/nightly
, that is a mistake that could be happening with current users (e.g., someone is looking atstable
docs and wants the latest, so they just change the URL in the browser tomaster
).This
static-router
redirect should really only be hit when coming from an old forum post or similar (it was Rust 0.17 docs, after all). Sincestable
is the default for any miscellaneous path ondoc-router
, it seems like the appropriate redirect target here.Redirecting to doc.rust-lang.org
I decided to redirect to
//doc.rust-lang.org
instead of stay on//static.rust-lang.org
, because there could be some helpful error handling or other redirects indoc-router
that we'd want to take advantage of. Also, it is the preferred entry point for all documentation, so it's best to keepstatic
as an implementation detail when possible.Close #568