Pass params to warp handler

Hello,
I am trying to figure out how to pass a parameter like a vector to my warp handler. I am getting unsatisfied trait bound errors.

Here is the code:

use warp::Filter;
use warp::http::StatusCode;
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize)]
pub struct Test {
    id: u64
}

pub async fn with_vec(vec: Vec<u8>) -> impl Filter<Extract = (Vec<u8>,), Error = std::convert::Infallible> + Clone {
    warp::any().map(move || {vec.clone()})
}

pub async fn handler(vec: Vec<u8>) -> Result<impl warp::Reply, warp::Rejection> {
    Ok(StatusCode::CREATED)
}

#[tokio::main]
async fn main() {
    let vec: Vec<u8> = vec![0u8; 256];

    let routes = warp::path!("hello")
    .and(with_vec(vec.clone()))
    .and_then(handler);

    warp::serve(routes).run(([127, 0, 0, 1], 8000)).await;
}

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.