Skip to content

Commit a48bc41

Browse files
committed
Use a proper http::HeaderName for the password header
It is a non-breaking change but still use the same name in both code and README.md for consistency.
1 parent 834146e commit a48bc41

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ To retrieve the raw content, make a GET request on the `/raw/:id` route. If you
176176
use a client that is able to handle cookies you can delete the paste once again
177177
using the cookie in the `Set-Cookie` header set during redirect after creation.
178178

179-
In case the paste was encrypted, pass the password via the `Wastebin-Password`
179+
In case the paste was encrypted, pass the password via the `wastebin-password`
180180
header.
181181

182182

src/handlers/extract.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ use serde::Deserialize;
44

55
pub struct Password(pub crypto::Password);
66

7+
/// Password header to encrypt a paste.
8+
pub const PASSWORD_HEADER_NAME: http::HeaderName =
9+
http::HeaderName::from_static("wastebin-password");
10+
711
#[axum::async_trait]
812
impl<S> FromRequest<S> for Password
913
where
@@ -19,7 +23,7 @@ where
1923

2024
if let Some(password) = req
2125
.headers()
22-
.get("Wastebin-Password")
26+
.get(PASSWORD_HEADER_NAME)
2327
.and_then(|header| header.to_str().ok())
2428
{
2529
return Ok(Password(password.as_bytes().to_vec().into()));

src/handlers/insert/api.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub async fn insert(
5959
#[cfg(test)]
6060
mod tests {
6161
use crate::db::write::Entry;
62+
use crate::handlers::extract::PASSWORD_HEADER_NAME;
6263
use crate::test_helpers::Client;
6364
use reqwest::StatusCode;
6465

@@ -113,7 +114,7 @@ mod tests {
113114

114115
let res = client
115116
.get(&format!("/raw{}", payload.path))
116-
.header("Wastebin-Password", password)
117+
.header(PASSWORD_HEADER_NAME, password)
117118
.send()
118119
.await?;
119120

0 commit comments

Comments
 (0)