Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Credentials::decode() should return Result instead of Option #71

Open
bwalter opened this issue Apr 16, 2020 · 0 comments
Open

Credentials::decode() should return Result instead of Option #71

bwalter opened this issue Apr 16, 2020 · 0 comments

Comments

@bwalter
Copy link

bwalter commented Apr 16, 2020

I'm using "headers" together with warp to decode basic auth headers. With the current behaviour, my web server would panic if the header value does not start with "Basic ".

It would be great in my opinion if Credentials::decode() could return a Result instead of an Option. In the above use case, Basic::decode() would return an Err instead of panicking.

Current behavior:

let header_value = http::header::HeaderValue::from_static("Bazic xxx");
let basic = Basic::decode(&header_value);  // panic

Feature request (with error handling):

let header_value = http::header::HeaderValue::from_static("Bazic xxx");
let basic = Basic::decode(&header_value).map_err(...)?;  // proper error handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant