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
10 changed files with 21 additions and 0 deletions
+3
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`
@@ -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;
+2
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));
+2
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));
+2
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();
+2
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));
+2
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",
+2
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)
+2
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;
+2
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));