Struct rocket_basicauth::BasicAuth[][src]

pub struct BasicAuth {
    pub username: String,
    pub password: String,
}
Expand description

A high-level basic access authentication request guard implementation, containing the username and password used for authentication

Example

#[macro_use] extern crate rocket;

use rocket_basicauth::BasicAuth;

/// Hello route with `auth` request guard, containing a `username` and `password`
#[get("/hello/<age>")]
fn hello(auth: BasicAuth, age: u8) -> String {
    format!("Hello, {} year old named {}!", age, auth.username)
}

#[launch]
fn rocket() -> _ {
    rocket::build().mount("/", routes![hello])
}

Fields

username: String

Required username

password: String

Required password

Implementations

Creates a new BasicAuth struct/request guard from a given plaintext http auth header or returns a Option::None if invalid

Trait Implementations

Formats the value using the given formatter. Read more

The associated error to be returned if derivation fails.

Derives an instance of Self from the incoming request metadata. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Converts self into a collection.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.