pub struct ChioService<S> { /* private fields */ }Expand description
Tower Service that evaluates HTTP requests against the Chio kernel.
For each request, the service:
- Extracts the caller identity from request headers
- Evaluates the request against the Chio policy
- If denied, returns a 403 JSON error response
- If allowed, forwards to the inner service with receipt ID in response headers
Request bodies must be replayable after inspection. The current middleware
supports body types that implement both http_body::Body and From<Bytes>.
Implementations§
Source§impl<S> ChioService<S>
impl<S> ChioService<S>
Sourcepub fn new(inner: S, evaluator: ChioEvaluator) -> Self
pub fn new(inner: S, evaluator: ChioEvaluator) -> Self
Create a new Chio service wrapping the inner service.
Sourcepub fn with_max_body_bytes(self, max_body_bytes: usize) -> Self
pub fn with_max_body_bytes(self, max_body_bytes: usize) -> Self
Override the maximum body size buffered for hashing.
Requests whose advertised or observed body size exceeds this limit are
rejected with 413 Payload Too Large before reaching the inner
service. Defaults to DEFAULT_MAX_BODY_BYTES.
Trait Implementations§
Source§impl<S: Clone> Clone for ChioService<S>
impl<S: Clone> Clone for ChioService<S>
Source§fn clone(&self) -> ChioService<S>
fn clone(&self) -> ChioService<S>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<S, ReqBody, ResBody> Service<Request<ReqBody>> for ChioService<S>where
S: Service<Request<ReqBody>, Response = Response<ResBody>> + Clone + Send + 'static,
S::Future: Send,
S::Error: Into<Box<dyn Error + Send + Sync>>,
ReqBody: Body + From<Bytes> + Send + 'static,
ReqBody::Data: Send,
ReqBody::Error: Into<Box<dyn Error + Send + Sync>>,
ResBody: Default + From<Bytes> + Send + 'static,
impl<S, ReqBody, ResBody> Service<Request<ReqBody>> for ChioService<S>where
S: Service<Request<ReqBody>, Response = Response<ResBody>> + Clone + Send + 'static,
S::Future: Send,
S::Error: Into<Box<dyn Error + Send + Sync>>,
ReqBody: Body + From<Bytes> + Send + 'static,
ReqBody::Data: Send,
ReqBody::Error: Into<Box<dyn Error + Send + Sync>>,
ResBody: Default + From<Bytes> + Send + 'static,
Source§type Future = Pin<Box<dyn Future<Output = Result<<ChioService<S> as Service<Request<ReqBody>>>::Response, <ChioService<S> as Service<Request<ReqBody>>>::Error>> + Send>>
type Future = Pin<Box<dyn Future<Output = Result<<ChioService<S> as Service<Request<ReqBody>>>::Response, <ChioService<S> as Service<Request<ReqBody>>>::Error>> + Send>>
The future response value.
Auto Trait Implementations§
impl<S> !RefUnwindSafe for ChioService<S>
impl<S> !UnwindSafe for ChioService<S>
impl<S> Freeze for ChioService<S>where
S: Freeze,
impl<S> Send for ChioService<S>where
S: Send,
impl<S> Sync for ChioService<S>where
S: Sync,
impl<S> Unpin for ChioService<S>where
S: Unpin,
impl<S> UnsafeUnpin for ChioService<S>where
S: UnsafeUnpin,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T, Request> ServiceExt<Request> for T
impl<T, Request> ServiceExt<Request> for T
Source§fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
Yields a mutable reference to the service when it is ready to accept a request.
Source§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
Yields the service when it is ready to accept a request.
Source§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
Consume this
Service, calling it with the provided request once it is ready.Source§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
Executes a new future after this service’s future resolves. This does
not alter the behaviour of the
poll_ready method. Read moreSource§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
Maps this service’s response value to a different value. This does not
alter the behaviour of the
poll_ready method. Read moreSource§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
Maps this service’s error value to a different value. This does not
alter the behaviour of the
poll_ready method. Read moreSource§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
Maps this service’s result type (
Result<Self::Response, Self::Error>)
to a different value, regardless of whether the future succeeds or
fails. Read moreSource§fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
Composes a function in front of the service. Read more
Source§fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
Composes an asynchronous function after this service. Read more
Source§fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
Composes a function that transforms futures produced by the service. Read more