aboutsummaryrefslogtreecommitdiff
path: root/src/handlers/mod.rs
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2020-10-02 18:36:57 -0400
committerGitHub <noreply@github.com>2020-10-02 18:36:57 -0400
commitfa13e57835e487d586024a2e065e8f4b30dc88cd (patch)
treee62623fec8d1f3e376453cb33ad0e42b2019b589 /src/handlers/mod.rs
parenta6ee2e7e36e8e8fac6f7c5f452cd6a0a06790584 (diff)
downloadxesite-fa13e57835e487d586024a2e065e8f4b30dc88cd.tar.xz
xesite-fa13e57835e487d586024a2e065e8f4b30dc88cd.zip
incorporate tracing instead of log (#222)
* incorporate tracing instead of log * fix a test * fix a test
Diffstat (limited to 'src/handlers/mod.rs')
-rw-r--r--src/handlers/mod.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs
index 5c51352..d180a11 100644
--- a/src/handlers/mod.rs
+++ b/src/handlers/mod.rs
@@ -9,6 +9,7 @@ use warp::{
http::{Response, StatusCode},
Rejection, Reply,
};
+use tracing::instrument;
lazy_static! {
static ref HIT_COUNTER: IntCounterVec =
@@ -16,27 +17,32 @@ lazy_static! {
.unwrap();
}
+#[instrument]
pub async fn index() -> Result<impl Reply, Rejection> {
HIT_COUNTER.with_label_values(&["index"]).inc();
Response::builder().html(|o| templates::index_html(o))
}
+#[instrument]
pub async fn contact() -> Result<impl Reply, Rejection> {
HIT_COUNTER.with_label_values(&["contact"]).inc();
Response::builder().html(|o| templates::contact_html(o))
}
+#[instrument]
pub async fn feeds() -> Result<impl Reply, Rejection> {
HIT_COUNTER.with_label_values(&["feeds"]).inc();
Response::builder().html(|o| templates::feeds_html(o))
}
+#[instrument(skip(state))]
pub async fn resume(state: Arc<State>) -> Result<impl Reply, Rejection> {
HIT_COUNTER.with_label_values(&["resume"]).inc();
let state = state.clone();
Response::builder().html(|o| templates::resume_html(o, Html(state.resume.clone())))
}
+#[instrument(skip(state))]
pub async fn patrons(state: Arc<State>) -> Result<impl Reply, Rejection> {
HIT_COUNTER.with_label_values(&["patrons"]).inc();
let state = state.clone();
@@ -51,12 +57,14 @@ pub async fn patrons(state: Arc<State>) -> Result<impl Reply, Rejection> {
}
}
+#[instrument(skip(state))]
pub async fn signalboost(state: Arc<State>) -> Result<impl Reply, Rejection> {
HIT_COUNTER.with_label_values(&["signalboost"]).inc();
let state = state.clone();
Response::builder().html(|o| templates::signalboost_html(o, state.signalboost.clone()))
}
+#[instrument]
pub async fn not_found() -> Result<impl Reply, Rejection> {
HIT_COUNTER.with_label_values(&["not_found"]).inc();
Response::builder().html(|o| templates::notfound_html(o, "some path".into()))
@@ -109,6 +117,7 @@ lazy_static! {
.unwrap();
}
+#[instrument]
pub async fn rejection(err: Rejection) -> Result<impl Reply, Infallible> {
let path: String;
let code;