Struct GrpcErrorsAsFailures
pub struct GrpcErrorsAsFailures { /* private fields */ }
Response classifier for gRPC responses.
gRPC doesn't use normal HTTP statuses for indicating success or failure but instead a special header that might appear in a trailer.
Responses are considered successful if
grpc-statusheader value contains a success value.grpc-statusheader is missing.grpc-statusheader value isn't a validString.grpc-statusheader value can't parsed into ani32.
All others are considered failures.
Implementations
impl GrpcErrorsAsFailures
fn new() -> SelfCreate a new
GrpcErrorsAsFailures.fn with_success(self, code: GrpcCode) -> SelfChange which gRPC codes are considered success.
Defaults to only considering
Okas success.Okwill always be considered a success.Example
Servers might not want to consider
Invalid ArgumentorNot Foundas failures since thats likely the clients fault:use tower_http::classify::{GrpcErrorsAsFailures, GrpcCode}; let classifier = GrpcErrorsAsFailures::new() .with_success(GrpcCode::InvalidArgument) .with_success(GrpcCode::NotFound);fn make_classifier() -> SharedClassifier<Self>Returns a
MakeClassifierthat producesGrpcErrorsAsFailures.This is a convenience function that simply calls
SharedClassifier::new.
Trait Implementations
impl ClassifyResponse for GrpcErrorsAsFailures
type FailureClass = GrpcFailureClass;type ClassifyEos = GrpcEosErrorsAsFailures;fn classify_response<B>(self, res: &Response<B>) -> ClassifiedResponse<Self::FailureClass, Self::ClassifyEos>fn classify_error<E>(self, error: &E) -> Self::FailureClass where E: Display + 'static,
impl Clone for GrpcErrorsAsFailures
fn clone(&self) -> Self
impl Debug for GrpcErrorsAsFailures
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for GrpcErrorsAsFailures
fn default() -> Self