Skip to content

Conversation

@AsamK
Copy link
Contributor

@AsamK AsamK commented Nov 26, 2022

Based on #95, but just adds impl Display

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

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

@m1guelpf
Copy link

Any updates on this?

@LeoniePhiline
Copy link

ping :) @seanmonstar

@seanmonstar
Copy link
Member

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

@LeoniePhiline
Copy link

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

@pongsakornsemsuwan
Copy link

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

@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