Commit Graph
4 Commits
Author SHA1 Message Date
Florian Thelliez d9a06ef14b Remove axum::prelude (#195) 2021-08-18 00:04:15 +02:00
David Pedersen 97c140cdf7 Add Headers response (#193)
* Add `Headers`

Example usage:

```rust
use axum::{
    route,
    routing::RoutingDsl,
    response::{IntoResponse, Headers},
    handler::get,
};
use http::header::{HeaderName, HeaderValue};

// It works with any `IntoIterator<Item = (Key, Value)>` where `Key` can be
// turned into a `HeaderName` and `Value` can be turned into a `HeaderValue`
//
// Such as `Vec<(HeaderName, HeaderValue)>`
async fn just_headers() -> impl IntoResponse {
    Headers(vec![
        (HeaderName::from_static("X-Foo"), HeaderValue::from_static("foo")),
    ])
}

// Or `[(&str, &str)]`
async fn from_strings() -> impl IntoResponse {
    Headers([("X-Foo", "foo")])
}
```

Fixes https://github.com/tokio-rs/axum/issues/187

* Make work on Rust versions without `IntoIterator` for arrays

* format

* changelog
2021-08-17 17:28:02 +02:00
David Pedersen b4cbd7f147 Add Redirect response (#192)
* Add `Redirect` response

* Add `Redirect::found`
2021-08-16 19:48:03 +02:00
Kai Jewson 9cd543401f Implement SSE using responses (#98) 2021-08-14 17:29:09 +02:00