Including tracing setup in all examples (#79)

This commit is contained in:
David Pedersen 2021-08-01 22:01:33 +02:00 committed by GitHub
parent 6d787665d6
commit 666d088b26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 21 additions and 0 deletions

View file

@ -33,6 +33,9 @@ use std::net::SocketAddr;
#[tokio::main]
async fn main() {
// initialize tracing
tracing_subscriber::fmt::init();
// build our application with a route
let app =
// `GET /` goes to `root`

View file

@ -18,6 +18,8 @@ use uuid::Uuid;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
// Inject a `UserRepo` into our handlers via a trait object. This could be
// the live implementation or just a mock for testing.
let user_repo = Arc::new(ExampleUserRepo) as DynUserRepo;

View file

@ -4,6 +4,8 @@ use std::net::SocketAddr;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
// build our application with some routes
let app = route("/", get(show_form).post(accept_form));

View file

@ -3,6 +3,8 @@ use std::net::SocketAddr;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
// build our application with a route
let app = route("/", get(handler));

View file

@ -14,6 +14,8 @@ use uuid::Uuid;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
// `MemoryStore` just used as an example. Don't use this in production.
let store = MemoryStore::new();

View file

@ -5,6 +5,8 @@ use std::net::SocketAddr;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
// build our application with some routes
let app = route("/greet/:name", get(greet));

View file

@ -11,6 +11,8 @@ use tokio_rustls::{
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let rustls_config = rustls_server_config(
"examples/self_signed_certs/key.pem",
"examples/self_signed_certs/cert.pem",

View file

@ -7,6 +7,8 @@ use tokio_postgres::NoTls;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
// setup connection pool
let manager =
PostgresConnectionManager::new_from_stringlike("host=localhost user=postgres", NoTls)

View file

@ -30,6 +30,8 @@ fn main() {
#[cfg(unix)]
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let path = PathBuf::from("/tmp/axum/helloworld");
let _ = tokio::fs::remove_file(&path).await;

View file

@ -10,6 +10,8 @@ use std::net::SocketAddr;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
// build our application with some routes
let app = route("/:version/foo", get(handler));