mirror of https://github.com/http-rs/tide
Merge pull request #755 from jbr/remove-logger-from-default-middleware
remove the logger from the default middleware
This commit is contained in:
commit
47866dd875
|
@ -4,6 +4,7 @@ async fn main() -> Result<(), std::io::Error> {
|
|||
use std::{env, net::TcpListener, os::unix::io::FromRawFd};
|
||||
tide::log::start();
|
||||
let mut app = tide::new();
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
app.at("/").get(|_| async { Ok(CHANGE_THIS_TEXT) });
|
||||
|
||||
const CHANGE_THIS_TEXT: &str = "hello world!";
|
||||
|
|
|
@ -4,6 +4,7 @@ use tide::Body;
|
|||
async fn main() -> Result<(), std::io::Error> {
|
||||
tide::log::start();
|
||||
let mut app = tide::new();
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
app.at("/").get(|_| async {
|
||||
// File sends are chunked by default.
|
||||
Ok(Body::from_file(file!()).await?)
|
||||
|
|
|
@ -4,6 +4,7 @@ use tide::Request;
|
|||
async fn main() -> Result<(), std::io::Error> {
|
||||
tide::log::start();
|
||||
let mut app = tide::new();
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
|
||||
app.at("/").get(|request: Request<_>| async move {
|
||||
Ok(format!(
|
||||
|
|
|
@ -23,6 +23,7 @@ async fn remove_cookie(_req: Request<()>) -> tide::Result {
|
|||
async fn main() -> Result<(), std::io::Error> {
|
||||
tide::log::start();
|
||||
let mut app = tide::new();
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
|
||||
app.at("/").get(retrieve_cookie);
|
||||
app.at("/set").get(insert_cookie);
|
||||
|
|
|
@ -7,6 +7,7 @@ use tide::{Body, Request, Response, Result, StatusCode};
|
|||
async fn main() -> Result<()> {
|
||||
tide::log::start();
|
||||
let mut app = tide::new();
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
|
||||
app.with(After(|mut res: Response| async {
|
||||
if let Some(err) = res.downcast_error::<async_std::io::Error>() {
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#[async_std::main]
|
||||
async fn main() -> Result<(), std::io::Error> {
|
||||
tide::log::start();
|
||||
|
||||
let mut app = tide::new();
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
|
||||
app.at("/").get(|_| async { Ok("Hello, world!") });
|
||||
app.listen("127.0.0.1:8080").await?;
|
||||
Ok(())
|
||||
|
|
|
@ -11,6 +11,7 @@ struct Cat {
|
|||
async fn main() -> tide::Result<()> {
|
||||
tide::log::start();
|
||||
let mut app = tide::new();
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
|
||||
app.at("/submit").post(|mut req: Request<()>| async move {
|
||||
let cat: Cat = req.body_json().await?;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
async fn main() -> Result<(), std::io::Error> {
|
||||
tide::log::start();
|
||||
let mut app = tide::new();
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
app.at("/").get(|_| async { Ok("Root") });
|
||||
app.at("/api").nest({
|
||||
let mut api = tide::new();
|
||||
|
|
|
@ -4,6 +4,7 @@ use tide::{Redirect, Response, StatusCode};
|
|||
async fn main() -> Result<(), std::io::Error> {
|
||||
tide::log::start();
|
||||
let mut app = tide::new();
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
app.at("/").get(|_| async { Ok("Root") });
|
||||
|
||||
// Redirect hackers to YouTube.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
async fn main() -> Result<(), std::io::Error> {
|
||||
tide::log::start();
|
||||
let mut app = tide::new();
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
|
||||
app.with(tide::sessions::SessionMiddleware::new(
|
||||
tide::sessions::MemoryStore::new(),
|
||||
|
|
|
@ -4,6 +4,7 @@ use tide::sse;
|
|||
async fn main() -> Result<(), std::io::Error> {
|
||||
tide::log::start();
|
||||
let mut app = tide::new();
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
app.at("/sse").get(sse::endpoint(|_req, sender| async move {
|
||||
sender.send("fruit", "banana", None).await?;
|
||||
sender.send("fruit", "apple", None).await?;
|
||||
|
|
|
@ -18,6 +18,7 @@ impl State {
|
|||
async fn main() -> tide::Result<()> {
|
||||
tide::log::start();
|
||||
let mut app = tide::with_state(State::new());
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
app.at("/").get(|req: tide::Request<State>| async move {
|
||||
let state = req.state();
|
||||
let value = state.value.load(Ordering::Relaxed);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
async fn main() -> Result<(), std::io::Error> {
|
||||
tide::log::start();
|
||||
let mut app = tide::new();
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
app.at("/").get(|_| async { Ok("visit /src/*") });
|
||||
app.at("/src/*").serve_dir("src/")?;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ impl TempDirState {
|
|||
async fn main() -> Result<(), IoError> {
|
||||
tide::log::start();
|
||||
let mut app = tide::with_state(TempDirState::try_new()?);
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
|
||||
// To test this example:
|
||||
// $ cargo run --example upload
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
//!
|
||||
//! #[async_std::main]
|
||||
//! async fn main() -> tide::Result<()> {
|
||||
//! tide::log::start();
|
||||
//! let mut app = tide::new();
|
||||
//! app.with(tide::log::LogMiddleware::new());
|
||||
//! app.at("/orders/shoes").post(order_shoes);
|
||||
//! app.listen("127.0.0.1:8080").await?;
|
||||
//! Ok(())
|
||||
|
|
|
@ -109,8 +109,6 @@ where
|
|||
middleware: Arc::new(vec![
|
||||
#[cfg(feature = "cookies")]
|
||||
Arc::new(cookies::CookiesMiddleware::new()),
|
||||
#[cfg(feature = "logger")]
|
||||
Arc::new(log::LogMiddleware::new()),
|
||||
]),
|
||||
state,
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ async fn test_server_listen(logger: &mut logtest::Logger) {
|
|||
|
||||
async fn test_only_log_once(logger: &mut logtest::Logger) -> tide::Result<()> {
|
||||
let mut app = tide::new();
|
||||
app.with(tide::log::LogMiddleware::new());
|
||||
app.at("/").nest({
|
||||
let mut app = tide::new();
|
||||
app.at("/").get(|_| async { Ok("nested") });
|
||||
|
|
Loading…
Reference in New Issue