mirror of
https://github.com/tokio-rs/axum.git
synced 2025-10-02 07:20:38 +00:00
Including tracing setup in all examples (#79)
This commit is contained in:
parent
6d787665d6
commit
666d088b26
@ -33,6 +33,9 @@ use std::net::SocketAddr;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
// initialize tracing
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
// build our application with a route
|
// build our application with a route
|
||||||
let app =
|
let app =
|
||||||
// `GET /` goes to `root`
|
// `GET /` goes to `root`
|
||||||
|
@ -18,6 +18,8 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
// Inject a `UserRepo` into our handlers via a trait object. This could be
|
// Inject a `UserRepo` into our handlers via a trait object. This could be
|
||||||
// the live implementation or just a mock for testing.
|
// the live implementation or just a mock for testing.
|
||||||
let user_repo = Arc::new(ExampleUserRepo) as DynUserRepo;
|
let user_repo = Arc::new(ExampleUserRepo) as DynUserRepo;
|
||||||
|
@ -4,6 +4,8 @@ use std::net::SocketAddr;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
// build our application with some routes
|
// build our application with some routes
|
||||||
let app = route("/", get(show_form).post(accept_form));
|
let app = route("/", get(show_form).post(accept_form));
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ use std::net::SocketAddr;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
// build our application with a route
|
// build our application with a route
|
||||||
let app = route("/", get(handler));
|
let app = route("/", get(handler));
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
// `MemoryStore` just used as an example. Don't use this in production.
|
// `MemoryStore` just used as an example. Don't use this in production.
|
||||||
let store = MemoryStore::new();
|
let store = MemoryStore::new();
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ use std::net::SocketAddr;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
// build our application with some routes
|
// build our application with some routes
|
||||||
let app = route("/greet/:name", get(greet));
|
let app = route("/greet/:name", get(greet));
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@ use tokio_rustls::{
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
let rustls_config = rustls_server_config(
|
let rustls_config = rustls_server_config(
|
||||||
"examples/self_signed_certs/key.pem",
|
"examples/self_signed_certs/key.pem",
|
||||||
"examples/self_signed_certs/cert.pem",
|
"examples/self_signed_certs/cert.pem",
|
||||||
|
@ -7,6 +7,8 @@ use tokio_postgres::NoTls;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
// setup connection pool
|
// setup connection pool
|
||||||
let manager =
|
let manager =
|
||||||
PostgresConnectionManager::new_from_stringlike("host=localhost user=postgres", NoTls)
|
PostgresConnectionManager::new_from_stringlike("host=localhost user=postgres", NoTls)
|
||||||
|
@ -30,6 +30,8 @@ fn main() {
|
|||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
let path = PathBuf::from("/tmp/axum/helloworld");
|
let path = PathBuf::from("/tmp/axum/helloworld");
|
||||||
|
|
||||||
let _ = tokio::fs::remove_file(&path).await;
|
let _ = tokio::fs::remove_file(&path).await;
|
||||||
|
@ -10,6 +10,8 @@ use std::net::SocketAddr;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
// build our application with some routes
|
// build our application with some routes
|
||||||
let app = route("/:version/foo", get(handler));
|
let app = route("/:version/foo", get(handler));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user