mirror of
https://github.com/tokio-rs/axum.git
synced 2025-01-11 12:31:25 +01:00
Including tracing setup in all examples (#79)
This commit is contained in:
parent
6d787665d6
commit
666d088b26
10 changed files with 21 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
Loading…
Reference in a new issue