Skip to content

How to add basic auth and headers? #22

Description

@merc1031

I am trying to convert some code to use rustify and i cannot find a way to add basic_auth. I can use Middleware to add headers (like content-type) but it feels a bit heavy handed

i am attempting to convert some code like this

let builder = client
    .post(&url)
    .basic_auth(
        username,
        Some(password.unsecure()),
    )
    .header("X-API-Token", token)
    .header("Content-type", "application/json");

to

#[derive(Builder, Debug, Clone, Endpoint)]
#[endpoint(path = "call/{self.name}/{self.number}/", method = "POST", builder = "true")]
#[builder(setter(into))]
struct Call {
    pub name: String,
    pub number: u32,
}
    let endpoint = Call::builder()
        .name(name)
        .number(number)
        .build()?;
 
    let client = Client::default(&url_base);
...

But i don't see an easy way to add the basic_auth.

Am I missing something?

Thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions