Commit Graph
7 Commits
Author SHA1 Message Date
Laurențiu Nicola 68f826ef3b Simplify tracing-subscriber initialization (#128) 2021-08-05 19:43:03 +02:00
Spencer GilbertandDavid Pedersen 3cd0c0fd45 Set RUST_LOG environment var for all examples using tracing (#123)
* Set RUST_LOG environment var for all examples using tracing

Signed-off-by: Spencer Gilbert <[email protected]>

* Update examples/multipart_form.rs

Co-authored-by: David Pedersen <[email protected]>
2021-08-05 11:25:03 +02:00
David Pedersen 5c12328892 Replace hyper::Server with axum::Server in docs (#118)
* Replace `hyper::Server` with `axum::Server` in docs

* Change readme as well
2021-08-04 15:38:51 +02:00
David Pedersen 9fbababc3a Make it clear how to run all examples (#92)
* Handle errors in websocket example

* Make it clear how to run all examples
2021-08-02 23:09:09 +02:00
David Pedersen 666d088b26 Including tracing setup in all examples (#79) 2021-08-01 22:01:33 +02:00
David Pedersen f67abd1ee2 Add extractor for remote connection info (#55)
Fixes https://github.com/tokio-rs/axum/issues/43

With this you can get the remote address like so:

```rust
use axum::{prelude::*, extract::ConnectInfo};
use std::net::SocketAddr;

let app = route("/", get(handler));

async fn handler(ConnectInfo(addr): ConnectInfo<SocketAddr>) -> String {
    format!("Hello {}", addr)
}

// Starting the app with `into_make_service_with_connect_info` is required
// for `ConnectInfo` to work.
let make_svc = app.into_make_service_with_connect_info::<SocketAddr, _>();

hyper::Server::bind(&"0.0.0.0:3000".parse().unwrap())
    .serve(make_svc)
    .await
    .expect("server failed");
```

This API is fully generic and supports whatever transport layer you're using with Hyper. I've updated the unix domain socket example to extract `peer_creds` and `peer_addr`.
2021-07-31 21:36:30 +02:00
David Pedersen 132da26d5b Add unix domain socket example (#53)
Not actually related to Axum, can be implemented directly with Hyper, but I figure its nice to have for demonstration and might help catch accidental breaking changes in the future.
2021-07-31 12:22:38 +02:00