pub struct Info<'a> { /* private fields */ }
Expand description
Information about the request/response that can be used to prepare log lines.
Implementations
sourceimpl<'a> Info<'a>
impl<'a> Info<'a>
sourcepub fn remote_addr(&self) -> Option<SocketAddr>
pub fn remote_addr(&self) -> Option<SocketAddr>
View the remote SocketAddr
of the request.
sourcepub fn method(&self) -> &Method
pub fn method(&self) -> &Method
View the http::Method
of the request.
Examples found in repository?
src/filters/log.rs (line 41)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
pub fn log(name: &'static str) -> Log<impl Fn(Info) + Copy> {
let func = move |info: Info| {
// TODO?
// - response content length?
log::info!(
target: name,
"{} \"{} {} {:?}\" {} \"{}\" \"{}\" {:?}",
OptFmt(info.route.remote_addr()),
info.method(),
info.path(),
info.route.version(),
info.status().as_u16(),
OptFmt(info.referer()),
OptFmt(info.user_agent()),
info.elapsed(),
);
};
Log { func }
}
sourcepub fn path(&self) -> &str
pub fn path(&self) -> &str
View the URI path of the request.
Examples found in repository?
src/filters/log.rs (line 42)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
pub fn log(name: &'static str) -> Log<impl Fn(Info) + Copy> {
let func = move |info: Info| {
// TODO?
// - response content length?
log::info!(
target: name,
"{} \"{} {} {:?}\" {} \"{}\" \"{}\" {:?}",
OptFmt(info.route.remote_addr()),
info.method(),
info.path(),
info.route.version(),
info.status().as_u16(),
OptFmt(info.referer()),
OptFmt(info.user_agent()),
info.elapsed(),
);
};
Log { func }
}
sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
View the http::StatusCode
of the response.
Examples found in repository?
src/filters/log.rs (line 44)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
pub fn log(name: &'static str) -> Log<impl Fn(Info) + Copy> {
let func = move |info: Info| {
// TODO?
// - response content length?
log::info!(
target: name,
"{} \"{} {} {:?}\" {} \"{}\" \"{}\" {:?}",
OptFmt(info.route.remote_addr()),
info.method(),
info.path(),
info.route.version(),
info.status().as_u16(),
OptFmt(info.referer()),
OptFmt(info.user_agent()),
info.elapsed(),
);
};
Log { func }
}
sourcepub fn referer(&self) -> Option<&str>
pub fn referer(&self) -> Option<&str>
View the referer of the request.
Examples found in repository?
src/filters/log.rs (line 45)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
pub fn log(name: &'static str) -> Log<impl Fn(Info) + Copy> {
let func = move |info: Info| {
// TODO?
// - response content length?
log::info!(
target: name,
"{} \"{} {} {:?}\" {} \"{}\" \"{}\" {:?}",
OptFmt(info.route.remote_addr()),
info.method(),
info.path(),
info.route.version(),
info.status().as_u16(),
OptFmt(info.referer()),
OptFmt(info.user_agent()),
info.elapsed(),
);
};
Log { func }
}
sourcepub fn user_agent(&self) -> Option<&str>
pub fn user_agent(&self) -> Option<&str>
View the user agent of the request.
Examples found in repository?
src/filters/log.rs (line 46)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
pub fn log(name: &'static str) -> Log<impl Fn(Info) + Copy> {
let func = move |info: Info| {
// TODO?
// - response content length?
log::info!(
target: name,
"{} \"{} {} {:?}\" {} \"{}\" \"{}\" {:?}",
OptFmt(info.route.remote_addr()),
info.method(),
info.path(),
info.route.version(),
info.status().as_u16(),
OptFmt(info.referer()),
OptFmt(info.user_agent()),
info.elapsed(),
);
};
Log { func }
}
sourcepub fn elapsed(&self) -> Duration
pub fn elapsed(&self) -> Duration
View the Duration
that elapsed for the request.
Examples found in repository?
src/filters/log.rs (line 47)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
pub fn log(name: &'static str) -> Log<impl Fn(Info) + Copy> {
let func = move |info: Info| {
// TODO?
// - response content length?
log::info!(
target: name,
"{} \"{} {} {:?}\" {} \"{}\" \"{}\" {:?}",
OptFmt(info.route.remote_addr()),
info.method(),
info.path(),
info.route.version(),
info.status().as_u16(),
OptFmt(info.referer()),
OptFmt(info.user_agent()),
info.elapsed(),
);
};
Log { func }
}
sourcepub fn request_headers(&self) -> &HeaderMap
pub fn request_headers(&self) -> &HeaderMap
Access the full headers of the request
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Info<'a>
impl<'a> Send for Info<'a>
impl<'a> Sync for Info<'a>
impl<'a> Unpin for Info<'a>
impl<'a> !UnwindSafe for Info<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self