Skip to content

Instantly share code, notes, and snippets.

@KiChjang
Last active January 20, 2016 00:14
Show Gist options
  • Save KiChjang/cccda44db89bb4195d79 to your computer and use it in GitHub Desktop.
Save KiChjang/cccda44db89bb4195d79 to your computer and use it in GitHub Desktop.
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