Skip to content

Implement Display for Referer#122

Merged
seanmonstar merged 1 commit into
hyperium:masterfrom
AsamK:referer-display
Jan 3, 2024
Merged

Implement Display for Referer#122
seanmonstar merged 1 commit into
hyperium:masterfrom
AsamK:referer-display

Conversation

@AsamK

@AsamK AsamK commented Nov 26, 2022

Copy link
Copy Markdown
Contributor

Based on #95, but just adds impl Display

Based on hyperium#95, but just adds impl Display
@LeoniePhiline

Copy link
Copy Markdown

This would be very great to have reviewed and merged! :)

@m1guelpf

Copy link
Copy Markdown

Any updates on this?

@LeoniePhiline

Copy link
Copy Markdown

ping :) @seanmonstar

@seanmonstar

Copy link
Copy Markdown
Member

There's no need to ping the issue/me multiple times.

@LeoniePhiline

Copy link
Copy Markdown

It unfortunately appeared quite as if all activity without a personal mention had gone unnoticed.

@pongsakornsemsuwan

Copy link
Copy Markdown

Hi,
What's everyone workaround while waiting for this PR?
I think we can use custom header but I don't want client to manually put it.

@LeoniePhiline

Copy link
Copy Markdown

@pongsakornsemsuwan HeaderMap::get():

async fn newsletter_subscribe<P: NewsletterSubscriptionProvider, M: Mailer + 'static>(
    // Cannot currently use Typed headers, as Referer does not (yet) implement Display: https://github.com/hyperium/headers/pull/122
    // TypedHeader(user_agent): TypedHeader<UserAgent>,
    // TypedHeader(referrer): TypedHeader<axum::headers::Referer>,
    headers: HeaderMap,
    InsecureClientIp(user_ip): InsecureClientIp,
    State(state): State<Arc<NewsletterState<P, M>>>,
    ValidatedJson(payload): ValidatedJson<SubscribeRequest>,
) -> Result<impl IntoResponse> {
    let referrer = match headers.get(header::REFERER) {
        Some(header_value) => header_value
            .to_str()
            .map_err(ClientError::HeaderToStrError)?,
        None => "https://www.example.com",
    };
    let user_agent = match headers.get(header::USER_AGENT) {
        Some(header_value) => header_value
            .to_str()
            .map_err(ClientError::HeaderToStrError)?,
        None => "",
    };

@seanmonstar seanmonstar merged commit e0323f5 into hyperium:master Jan 3, 2024
@AsamK AsamK deleted the referer-display branch January 3, 2024 19:36
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

Successfully merging this pull request may close these issues.

6 participants