In Rust using warp, how do I build filters by configuration?

72 Views Asked by At

Starting with a root path:

let root = warp::path::end()
  .map(|| "Hello World, at root!");

I would like to construct .or() Filters by configuration:

for path in web_server_config.paths {
  root.or(warp::path(path).map(|| "OK"));  // or any configurable response
}

I understand now that root is cloned into or() and returns a new instance and a different type that wraps the original type. So I would make root mutable and reassign on each result of or(), but I don't how to type root correctly so that it can accept or() results, and satisfy warp::serve

0

There are 0 best solutions below