Created
January 27, 2021 21:54
-
-
Save algermissen/038c1bdce5c9330fd355d25f491e55bd to your computer and use it in GitHub Desktop.
Warp auth example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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