rust 如何在Poem Web中查看导致400的请求

mzaanser  于 2023-05-17  发布在  其他
关注(0)|答案(1)|浏览(100)

我正在使用poem-web构建Web服务,但我收到了一个400错误的端点请求,但日志只显示

2023-05-16T05:45:45.190235Z DEBUG hyper::proto::h1::io: parsed 12 headers
2023-05-16T05:45:45.190280Z DEBUG hyper::proto::h1::conn: incoming body is content-length (1592 bytes)
2023-05-16T05:45:45.190346Z DEBUG hyper::proto::h1::conn: incoming body completed
2023-05-16T05:45:45.191518Z DEBUG hyper::proto::h1::io: flushed 220 bytes

跟踪按如下方式启动

if env::var_os("RUST_LOG").is_none() {
        env::set_var("RUST_LOG", "poem=debug");
    }
    tracing_subscriber::fmt::init();

有谁知道我如何才能看到导致400响应的请求的正文?

qvtsj1bj

qvtsj1bj1#

连接Tracing中间件,它调用内部的tracing crate方法。

use poem::middleware::Tracing;
let app = Route::new().at("/", index).with(Tracing);

运行RUST_LOG=TRACE ./target/debug/app-name。但我相信你没有正确登记路线。

相关问题