Skip to content

Instantly share code, notes, and snippets.

@algermissen
Created January 27, 2021 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save algermissen/038c1bdce5c9330fd355d25f491e55bd to your computer and use it in GitHub Desktop.
Save algermissen/038c1bdce5c9330fd355d25f491e55bd to your computer and use it in GitHub Desktop.
Warp auth example
pub fn auth(
provider: AuthProvider,
) -> impl Filter<Extract = (Context,), Error = warp::Rejection> + Clone { Ok(Context{})}
fn routes(
ap: &AuthProvider,
) -> impl Filter<Extract = impl warp::Reply, Error = Infallible> + Clone {
let g = auth(ap.clone())
.and(warp::get())
.and_then(get_handler);
let p = auth(ap.clone())
.and(warp::put())
.and(json_body(1024))
.and_then(put_handler);
g.or(p).recover(handle_rejection)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment