Function warp::filters::path::full

source ·
pub fn full() -> impl Filter<Extract = (FullPath,), Error = Infallible> + Copy
Expand description

Returns the full request path, irrespective of other filters.

This will return a FullPath, which can be stringified to return the full path of the request.

This is more useful in generic pre/post-processing filters, and should probably not be used for request matching/routing.

§Example

use warp::{Filter, path::FullPath};
use std::{collections::HashMap, sync::{Arc, Mutex}};

let counts = Arc::new(Mutex::new(HashMap::new()));
let access_counter = warp::path::full()
    .map(move |path: FullPath| {
        let mut counts = counts.lock().unwrap();

        *counts.entry(path.as_str().to_string())
            .and_modify(|c| *c += 1)
            .or_insert(0)
    });

let route = warp::path("foo")
    .and(warp::path("bar"))
    .and(access_counter)
    .map(|count| {
        format!("This is the {}th visit to this URL!", count)
    });