pub struct PolicyService<S, P> { /* private fields */ }Expand description
The service a ContentSecurityPolicy or PermissionsPolicy layer wraps routes in.
Not used directly: router.layer(policy) builds it.
§Examples
use axum::{Router, routing::get};
use ocre::security::{PermissionsPolicy, PolicyService};
use tower_layer::Layer as _;
let router: Router = Router::new().route("/", get(|| async { "home" }));
let service: PolicyService<Router, PermissionsPolicy> = PermissionsPolicy::new().layer(router);Trait Implementations§
Source§impl<S: Clone, P> Clone for PolicyService<S, P>
impl<S: Clone, P> Clone for PolicyService<S, P>
Source§impl<S, P> Service<Request<Body>> for PolicyService<S, P>where
S: Service<Request, Response = Response, Error = Infallible> + Clone + Send + 'static,
S::Future: Send + 'static,
P: Policy,
impl<S, P> Service<Request<Body>> for PolicyService<S, P>where
S: Service<Request, Response = Response, Error = Infallible> + Clone + Send + 'static,
S::Future: Send + 'static,
P: Policy,
Source§type Error = Infallible
type Error = Infallible
Errors produced by the service.
Source§type Future = Pin<Box<dyn Future<Output = Result<Response<Body>, Infallible>> + Send>>
type Future = Pin<Box<dyn Future<Output = Result<Response<Body>, Infallible>> + Send>>
The future response value.
Source§fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Infallible>>
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Infallible>>
Returns
Poll::Ready(Ok(())) when the service is able to process requests. Read moreAuto Trait Implementations§
impl<S, P> Freeze for PolicyService<S, P>where
S: Freeze,
impl<S, P> RefUnwindSafe for PolicyService<S, P>where
S: RefUnwindSafe,
P: RefUnwindSafe,
impl<S, P> Send for PolicyService<S, P>
impl<S, P> Sync for PolicyService<S, P>
impl<S, P> Unpin for PolicyService<S, P>where
S: Unpin,
impl<S, P> UnsafeUnpin for PolicyService<S, P>where
S: UnsafeUnpin,
impl<S, P> UnwindSafe for PolicyService<S, P>where
S: UnwindSafe,
P: RefUnwindSafe,
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
§fn into_make_service(self) -> IntoMakeService<S>
fn into_make_service(self) -> IntoMakeService<S>
Convert this service into a
MakeService, that is a [Service] whose
response is another service. Read more§fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
Convert this service into a
HandleError, that will handle errors
by converting them into responses. Read more§impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
§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.
§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.
§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.§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 more§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 more§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 more§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 more§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
§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
§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