Last active
January 20, 2016 00:14
-
-
Save KiChjang/cccda44db89bb4195d79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let handler = move |request: HyperRequest, response: HyperResponse| { | |
let redirects = match request.uri { | |
RequestUri::AbsolutePath(url) => | |
url.split("/").collect::<String>().parse::<u32>().unwrap_or(0) + 1, | |
RequestUri::AbsoluteUri(url) => | |
url.path().unwrap().first().unwrap().split("/").collect::<String>().parse::<u32>().unwrap_or(0) + 1, | |
_ => {} | |
}; | |
let url = | |
// Do some logic here to handle the case for the 20th redirect... | |
// response.status = StatusCode::Found; | |
format!("{host}/{redirects}", host = SERVER_HOST, redirects = redirects) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment