Skip to main content

WhenActive

Struct WhenActive 

Source
pub struct WhenActive { /* private fields */ }
Expand description

A route that is not there yet.

§Why 404 and not 403

A 403 is an admission. It says “there is something at this address, and you are not it” — which tells anyone who tries the URL that the feature exists, roughly what it is called, and that it is worth coming back for. Half-built features get found this way: somebody diffs the routes between two deploys, walks the ones that answer 403, and reads the names.

A route behind a flag that is off has not shipped. The honest answer, and the same one the router gives for a path nobody ever wrote, is 404 — and it is byte-for-byte the router’s own 404 here, because a body that differed would give the whole thing away again.

This is concealment, not authorization. It keeps a URL from being interesting; it does not keep anybody out. If the feature behind the flag must not be reachable by the people outside the rollout — because it costs money, or exposes somebody else’s data — put rustlavel_rbac::Can in front of it as well. A flag is a release tool.

§What it does to the request

On the way through, the ScopedFlags it resolved is attached to the request, so a handler that asks the same or another flag reuses the memo instead of running the resolvers again.

Implementations§

Source§

impl WhenActive

Source

pub fn new(flag: impl Into<String>) -> Self

Guard the routes below with one flag.

Source

pub fn flag(&self) -> &str

The flag this guard is checking.

Trait Implementations§

Source§

impl Clone for WhenActive

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WhenActive

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Middleware for WhenActive

Source§

fn handle(&self, request: Request, next: Next) -> BoxFuture<Response>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.