You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to write a get request where the user can enter something like host/id/<image_id> and get the desired image with that id. I read the documentation and tried this:
let get_image = warp::path::param().and_then(|id:String| asyncmove{if id != "0"{Ok(warp::fs::file(format!("./images/{}.png", id)))}else{Err(warp::reject::not_found())}});let routes = get_image;
warp::serve(routes).run(([0,0,0,0],3030)).await;
This gave me an error:
the trait bound impl warp::filter::FilterClone: warp::reply::Reply is not satisfied
required because of the requirements on the impl of warp::reply::Reply for (impl warp::filter::FilterClone,)rustc(E0277)
server.rs(25, 17): required by this bound in warp::server::serve
Can you help me explain how I can solve this?
thank you so much!
Best regards
Oscar
The text was updated successfully, but these errors were encountered:
I have the same issue. I would like to serve a file under a certain URL, but the path on local storage comes from the database.
Something like this:
use warp::Filter;use warp::Rejection;pubasyncfnget_path(_id:String) -> Result<String,Rejection>{// could make call to databaseOk("./README.md".into())}#[tokio::main]asyncfnmain(){
pretty_env_logger::init();let file = warp::path::param().and_then(get_path).map(|path:String| {// now serving the file at path// warp::fs::file_reply(...) ????// warp::reply::file(...) ????// analogous to:
warp::reply::html(path)});
warp::serve(file).run(([127,0,0,1],3030)).await;}
Do I see correctly that warp currently has no built in (public) reply helpers to do this? Even though something like this must already be somewhere since the warp::filters::fs::file filter exists?
I am trying to write a get request where the user can enter something like host/id/<image_id> and get the desired image with that id. I read the documentation and tried this:
This gave me an error:
the trait bound
impl warp::filter::FilterClone: warp::reply::Reply
is not satisfiedrequired because of the requirements on the impl of
warp::reply::Reply
for(impl warp::filter::FilterClone,)
rustc(E0277)server.rs(25, 17): required by this bound in
warp::server::serve
Can you help me explain how I can solve this?
thank you so much!
Best regards
Oscar
The text was updated successfully, but these errors were encountered: