pub async fn validate_token<B>(
req: &Request<B>,
validator_url: &str,
) -> Result<bool>Expand description
Validate an authentication token from a request
This function extracts the token from the request headers and validates it against an external authentication service.
§Arguments
req- The incoming HTTP request containing the tokenvalidator_url- URL of the external token validation service
§Returns
Ok(true)- Token is validOk(false)- Token is invalidErr(...)- Error occurred during validation
§Example
use tiny_proxy::auth::validator::validate_token;
use hyper::Request;
use bytes::Bytes;
use http_body_util::Empty;
let is_valid = validate_token(&req, "http://auth-service:8080/validate").await?;