Skip to content

Commit 9c7dc09

Browse files
committed
rmv emit_http_status_with_tokenserver_origin
1 parent 36e5683 commit 9c7dc09

2 files changed

Lines changed: 0 additions & 61 deletions

File tree

syncserver/src/server/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ macro_rules! build_app {
150150
.wrap_fn(tokenserver::logging::handle_request_log_line)
151151
.wrap_fn(middleware::rejectua::reject_user_agent)
152152
.wrap($cors)
153-
.wrap_fn(middleware::emit_http_status_with_tokenserver_origin)
154153
.service(
155154
web::resource(&cfg_path("/info/collections"))
156155
.route(web::get().to(handlers::get_collections)),
Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,2 @@
11
pub mod rejectua;
22
pub mod weave;
3-
4-
// # Web Middleware
5-
//
6-
// Matches the [Sync Storage middleware](https://github.com/mozilla-services/server-syncstorage/blob/master/syncstorage/tweens.py) (tweens).
7-
8-
use std::collections::HashMap;
9-
use std::future::Future;
10-
11-
use actix_web::{
12-
HttpMessage,
13-
dev::{Service, ServiceRequest, ServiceResponse},
14-
web::Data,
15-
};
16-
use syncserver_common::Metrics;
17-
use tokenserver_auth::TokenserverOrigin;
18-
19-
use crate::error::{ApiError, ApiErrorKind};
20-
use crate::server::ServerState;
21-
22-
pub fn emit_http_status_with_tokenserver_origin<B, S>(
23-
req: ServiceRequest,
24-
srv: &S,
25-
) -> impl Future<Output = Result<ServiceResponse<B>, actix_web::Error>> + use<B, S>
26-
where
27-
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error>,
28-
{
29-
let fut = srv.call(req);
30-
31-
async move {
32-
let res = fut.await?;
33-
let req = res.request();
34-
let metrics = {
35-
let statsd_client = req
36-
.app_data::<Data<ServerState>>()
37-
.map(|state| state.metrics.clone())
38-
.ok_or_else(|| ApiError::from(ApiErrorKind::NoServerState))?;
39-
40-
Metrics::from(&statsd_client)
41-
};
42-
43-
let mut tags = HashMap::default();
44-
if let Some(origin) = req.extensions().get::<TokenserverOrigin>().copied() {
45-
tags.insert("tokenserver_origin".to_string(), origin.to_string());
46-
};
47-
48-
if res.status().is_informational() {
49-
metrics.incr_with_tags("http_1XX", tags);
50-
} else if res.status().is_success() {
51-
metrics.incr_with_tags("http_2XX", tags);
52-
} else if res.status().is_redirection() {
53-
metrics.incr_with_tags("http_3XX", tags);
54-
} else if res.status().is_client_error() {
55-
metrics.incr_with_tags("http_4XX", tags);
56-
} else if res.status().is_server_error() {
57-
metrics.incr_with_tags("http_5XX", tags);
58-
}
59-
60-
Ok(res)
61-
}
62-
}

0 commit comments

Comments
 (0)