Skip to main content

Redirects

Struct Redirects 

Source
pub struct Redirects<'a> { /* private fields */ }
Expand description

HTTP(S) redirects by host name, from Client::redirects.

A redirect lives on a host name inside a zone, and access to it is access to that zone: the zone’s key, a member of the zone, or an Admin. Creating one makes Core add the DNS records that point the name at the platform; deleting it removes them.

Implementations§

Source§

impl<'a> Redirects<'a>

Source

pub async fn list( &self, zone_id: Option<Uuid>, page: PageRequest, ) -> Result<Page<Redirect>>

One page of the redirects of zone_id, or of every zone the caller can access when None (a zone key: its zone; an Admin: all). Without certificate status; read one redirect with get for that.

GET /api/v1/redirects[?zone_id=...]

§Errors

ErrorCode::Forbidden if the caller has no access to zone_id.

Source

pub async fn list_all(&self, zone_id: Option<Uuid>) -> Result<Vec<Redirect>>

All redirects list would return, following pagination.

GET /api/v1/redirects, as many times as there are pages.

§Errors

As list.

Source

pub async fn get(&self, name: &str) -> Result<Redirect>

One redirect by host name, with its certificate status for tls = Auto.

GET /api/v1/redirects/:name

§Errors

ErrorCode::NotFound if there is no such redirect.

Source

pub async fn create(&self, redirect: &NewRedirect) -> Result<Redirect>

Creates a redirect and the DNS records that point its name at the platform; Relay starts answering HTTP(S) requests for the name. With tls = Auto Core starts issuing a certificate right away. Returns it with the name normalized.

POST /api/v1/redirects

§Errors
  • ErrorCode::Conflict if the name already has a redirect, is not inside the zone, belongs to a more specific hosted zone or is delegated away, already has A/AAAA/CNAME records of the user’s own, or (Auto) is covered by another certificate. ApiError::details lists the reasons.
  • ErrorCode::Validation for a bad name, code or URL.
§Examples
use dinio_sdk::models::{NewRedirect, RedirectTls};
use dinio_sdk::ops;

let zone = ops::find_zone_for_host(client, "go.example.com").await?;
let redirect = NewRedirect {
    zone_id: zone.uuid,
    name: "go.example.com".into(),
    code: 302,
    location: "https://example.com/landing".into(),
    tls: Some(RedirectTls::Auto),
};
client.redirects().create(&redirect).await?;
Source

pub async fn update( &self, name: &str, patch: &RedirectPatch, ) -> Result<Redirect>

Changes a redirect’s code, target and/or certificate source; fields left None stay as they are. Its DNS records do not change.

PATCH /api/v1/redirects/:name

§Errors
Source

pub async fn delete(&self, name: &str) -> Result<()>

Deletes a redirect with its DNS records and its automatic certificate.

DELETE /api/v1/redirects/:name

§Errors

ErrorCode::NotFound if there is no such redirect.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Redirects<'a>

§

impl<'a> !UnwindSafe for Redirects<'a>

§

impl<'a> Freeze for Redirects<'a>

§

impl<'a> Send for Redirects<'a>

§

impl<'a> Sync for Redirects<'a>

§

impl<'a> Unpin for Redirects<'a>

§

impl<'a> UnsafeUnpin for Redirects<'a>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more