Skip to main content

RouteHandle

Struct RouteHandle 

Source
pub struct RouteHandle<'r> { /* private fields */ }
Expand description

Returned by get/post/… so a route can be named after registration.

Implementations§

Source§

impl RouteHandle<'_>

Source

pub fn name(self, name: &str) -> Self

Name the route for url_for and route:list.

Source

pub fn describe(self, summary: &str) -> Self

Say what this route does, in one line.

Documentation is attached here rather than kept in a separate file, so it cannot drift away from the route it describes.

Source

pub fn tag(self, tag: &str) -> Self

Group this route under a heading in generated documentation.

Source

pub fn responds(self, status: u16, description: &str) -> Self

Document a response this route can return.

Source

pub fn param(self, name: &str, description: &str) -> Self

Describe a parameter. Undescribed path parameters are still documented, just without prose.

Source

pub fn middleware(self, middleware: impl Middleware) -> Self

Add middleware to this one route.

A group is the right place for middleware several routes share. This is for the case a group cannot express: routes on one prefix that need different guards, which is what a resource with a permission per verb looks like — users.view on the index, users.delete on the delete. Without this, each verb needs a group of its own and the prefix stops reading as one resource.

It runs after the group’s middleware and before the handler.

Source

pub fn deprecated(self) -> Self

Mark the route as deprecated in generated documentation.

Source

pub fn deprecated_at(self, date: &str) -> Self

Say when the route was deprecated, as YYYY-MM-DD.

Responses then carry Deprecation: @<unix time> (RFC 9745), which is how a client library learns to warn its own developers. Implies RouteHandle::deprecated.

§Panics

On a date that is not YYYY-MM-DD — this is called at startup, with a literal, and a typo should fail there rather than send garbage.

Source

pub fn sunset(self, date: &str) -> Self

Say when the route will stop working, as YYYY-MM-DD.

Responses then carry Sunset (RFC 8594) with that date, and the route is marked deprecated. Nothing removes the route on the day — that is a deploy, and a person’s decision — but every client has been told.

§Panics

On a date that is not YYYY-MM-DD, for the reason given on RouteHandle::deprecated_at.

Auto Trait Implementations§

§

impl<'r> !RefUnwindSafe for RouteHandle<'r>

§

impl<'r> !UnwindSafe for RouteHandle<'r>

§

impl<'r> Freeze for RouteHandle<'r>

§

impl<'r> Send for RouteHandle<'r>

§

impl<'r> Sync for RouteHandle<'r>

§

impl<'r> Unpin for RouteHandle<'r>

§

impl<'r> UnsafeUnpin for RouteHandle<'r>

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> 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, 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.