// our authtoken validator, this queries the app state and the header
// `X-AuthToken` and compares the two. If there are any discrepancies, it
// returns `401 Unauthorized`.
//
// every handler & middleware takes and returns the same params and has the
// same prototype.
//
our authtoken validator, this queries the app state and the header
`X-AuthToken` and compares the two. If there are any discrepancies, it
returns `401 Unauthorized`.

every handler & middleware takes and returns the same params and has the
same prototype.
our authtoken validator this queries the app state and the header ` X - AuthToken ` and compares the two . If there are any discrepancies it returns ` 401 Unauthorized ` . every handler & middleware takes and returns the same params and has the same prototype .
async fn validate_authtoken(
    req: Request<Body>,
    resp: Option<Response<Body>>,
    _params: Params,
    app: App<State, AuthedState>,
    mut authstate: AuthedState,
) -> HTTPResult<AuthedState> {
    if let (Some(token), Some(state)) = (req.headers().get("X-AuthToken"), app.state().await) {
        authstate.authed = Some(state.clone().lock().await.authtoken == token);
        Ok((req, resp, authstate))
    } else {
        Err(Error::StatusCode(
            StatusCode::UNAUTHORIZED,
            String::default(),
        ))
    }
}
async fn validate_authtoken ( req : Request < Body > , resp : Option < Response < Body > > , _params : Params , app : App < State , AuthedState > , mut authstate : AuthedState , ) -> HTTPResult < AuthedState > { if let ( Some ( token ) , Some ( state ) ) = ( req . headers ( ) . get ( " " ) , app . state ( ) . await ) { authstate . authed = Some ( state . clone ( ) . lock ( ) . await . authtoken == token ) ; Ok ( ( req , resp , authstate ) ) } else { Err ( Error :: StatusCode ( StatusCode :: UNAUTHORIZED , String :: default ( ) , ) ) } }
our authtoken validator, this queries the app state and the header
`X-AuthToken` and compares the two.
our authtoken validator this queries the app state and the header ` X - AuthToken ` and compares the two .
req
Request<Body>
resp
Option<Response<Body>>
_params
Params
app
App<State, AuthedState>
authstate
AuthedState