Struct StatusInRangeAsFailures
struct StatusInRangeAsFailures { ... }
Response classifier that considers responses with a status code within some range to be failures.
Example
A client with tracing where server errors and client errors are considered failures.
use tower_http::{trace::TraceLayer, classify::StatusInRangeAsFailures};
use tower::{ServiceBuilder, Service, ServiceExt};
use http::{Request, Method};
use http_body_util::Full;
use bytes::Bytes;
use hyper_util::{rt::TokioExecutor, client::legacy::Client};
# async fn foo() -> Result<(), tower::BoxError> {
let classifier = StatusInRangeAsFailures::new(400..=599);
let client = Client::builder(TokioExecutor::new()).build_http();
let mut client = ServiceBuilder::new()
.layer(TraceLayer::new(classifier.into_make_classifier()))
.service(client);
let request = Request::builder()
.method(Method::GET)
.uri("https://example.com")
.body(Full::<Bytes>::default())
.unwrap();
let response = client.ready().await?.call(request).await?;
# Ok(())
# }
Implementations
impl StatusInRangeAsFailures
fn new(range: RangeInclusive<u16>) -> SelfCreates a new
StatusInRangeAsFailures.Panics
Panics if the start or end of
rangearen't valid status codes as determined byStatusCode::from_u16.fn new_for_client_and_server_errors() -> SelfCreates a new
StatusInRangeAsFailuresthat classifies client and server responses as failures.This is a convenience for
StatusInRangeAsFailures::new(400..=599).fn into_make_classifier(self: Self) -> SharedClassifier<Self>Convert this
StatusInRangeAsFailuresinto aMakeClassifier.
impl ClassifyResponse for StatusInRangeAsFailures
fn classify_response<B>(self: Self, res: &Response<B>) -> ClassifiedResponse<<Self as >::FailureClass, <Self as >::ClassifyEos>fn classify_error<E>(self: Self, error: &E) -> <Self as >::FailureClass where E: Display + 'static
impl Clone for StatusInRangeAsFailures
fn clone(self: &Self) -> StatusInRangeAsFailures
impl Debug for StatusInRangeAsFailures
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Freeze for StatusInRangeAsFailures
impl RefUnwindSafe for StatusInRangeAsFailures
impl Send for StatusInRangeAsFailures
impl Sync for StatusInRangeAsFailures
impl Unpin for StatusInRangeAsFailures
impl UnsafeUnpin for StatusInRangeAsFailures
impl UnwindSafe for StatusInRangeAsFailures
impl<T> Any for StatusInRangeAsFailures
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for StatusInRangeAsFailures
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for StatusInRangeAsFailures
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for StatusInRangeAsFailures
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for StatusInRangeAsFailures
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for StatusInRangeAsFailures
impl<T> PolicyExt for StatusInRangeAsFailures
fn and<P, B, E>(self: Self, other: P) -> And<T, P> where T: Policy<B, E>, P: Policy<B, E>fn or<P, B, E>(self: Self, other: P) -> Or<T, P> where T: Policy<B, E>, P: Policy<B, E>
impl<T> ToOwned for StatusInRangeAsFailures
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T> WithSubscriber for StatusInRangeAsFailures
impl<T, U> Into for StatusInRangeAsFailures
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for StatusInRangeAsFailures
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for StatusInRangeAsFailures
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>