Preview:
async fn response(
    name: String,
    validator: Validator,
    remote: Option<SocketAddr>,
) -> Result<impl warp::Reply, warp::Rejection> {
    if let Some(addr) = remote {
        let ip_string = addr.ip().to_string();
        if validator.is_valid(ip_string.clone()).await {
            Ok(format!("Hello, {} from {}!", name, &ip_string))
        } else {
            Ok(format!("No key for {}!", &ip_string))
        }
    } else {
        Ok("No remote address!".to_string())
    }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter