Skip to content

Commit cb29fc7

Browse files
authored
Merge branch 'dev' into issue-260-preserve-original-error-message
2 parents c8ce73b + e984f60 commit cb29fc7

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

adapter/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ futures = { version = "0.3.1", features = ["compat"] }
3232

3333
[dev-dependencies]
3434
byteorder = "1.3"
35-
tokio = { version = "0.2", features = ["macros", "rt-core"] }
35+
tokio = { version = "0.2", features = ["macros", "rt-threaded"] }

sentry/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ hex = "0.3.2"
1616
# CLI
1717
clap = "2.33.0"
1818
# Server
19-
tokio = { version = "0.2.9", features = ["macros", "rt-core"] }
19+
tokio = { version = "0.2.9", features = ["macros", "rt-threaded"] }
2020
hyper = { version = "0.13", features = ["stream"] }
2121
regex = "1"
2222
# Database
23-
redis = { version = "0.14", features = ["tokio-rt-core"] }
24-
bb8 = { git = "https://github.com/khuey/bb8" }
25-
bb8-postgres = { git = "https://github.com/khuey/bb8", features = ["with-chrono-0_4", "with-serde_json-1"] }
23+
redis = "0.15"
24+
bb8 = "0.4"
25+
bb8-postgres = { version = "0.4", features = ["with-chrono-0_4", "with-serde_json-1"] }
2626

2727
# Migrations
2828
migrant_lib = { version = "0.27", features = ["d-postgres"] }

sentry/src/db.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ lazy_static! {
3636

3737
pub async fn redis_connection() -> Result<MultiplexedConnection, RedisError> {
3838
let client = redis::Client::open(REDIS_URL.as_str()).expect("Wrong redis connection url");
39-
client.get_multiplexed_tokio_connection().await
39+
let (connection, driver) = client.get_multiplexed_async_connection().await?;
40+
tokio::spawn(driver);
41+
Ok(connection)
4042
}
4143

4244
pub async fn postgres_connection() -> Result<DbPool, bb8_postgres::tokio_postgres::Error> {

sentry/src/lib.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ lazy_static! {
6060
static ref ANALYTICS_BY_CHANNEL_ID: Regex = Regex::new(r"^/analytics/0x([a-zA-Z0-9]{64})/?$").expect("The regex should be valid");
6161
static ref ADVERTISER_ANALYTICS_BY_CHANNEL_ID: Regex = Regex::new(r"^/analytics/for-advertiser/0x([a-zA-Z0-9]{64})/?$").expect("The regex should be valid");
6262
static ref PUBLISHER_ANALYTICS_BY_CHANNEL_ID: Regex = Regex::new(r"^/analytics/for-publisher/0x([a-zA-Z0-9]{64})/?$").expect("The regex should be valid");
63-
static ref CREATE_EVENTS_BY_CHANNEL_ID: Regex = Regex::new(r"^/channel/0x([a-zA-Z0-9]{64})/events(/.*)?$").expect("The regex should be valid");
64-
63+
static ref CREATE_EVENTS_BY_CHANNEL_ID: Regex = Regex::new(r"^/channel/0x([a-zA-Z0-9]{64})/events/?$").expect("The regex should be valid");
6564
}
6665

6766
fn auth_required_middleware<'a, A: Adapter>(
@@ -253,7 +252,16 @@ async fn channels_router<A: Adapter + 'static>(
253252
let (path, method) = (req.uri().path().to_owned(), req.method());
254253

255254
// regex matching for routes with params
256-
if let (Some(caps), &Method::GET) = (LAST_APPROVED_BY_CHANNEL_ID.captures(&path), method) {
255+
if let (Some(caps), &Method::POST) = (CREATE_EVENTS_BY_CHANNEL_ID.captures(&path), method) {
256+
let param = RouteParams(vec![caps
257+
.get(1)
258+
.map_or("".to_string(), |m| m.as_str().to_string())]);
259+
260+
req.extensions_mut().insert(param);
261+
262+
insert_events(req, app).await
263+
} else if let (Some(caps), &Method::GET) = (LAST_APPROVED_BY_CHANNEL_ID.captures(&path), method)
264+
{
257265
let param = RouteParams(vec![caps
258266
.get(1)
259267
.map_or("".to_string(), |m| m.as_str().to_string())]);
@@ -332,16 +340,6 @@ async fn channels_router<A: Adapter + 'static>(
332340
let req = chain(req, app, vec![Box::new(channel_load)]).await?;
333341

334342
list_channel_event_aggregates(req, app).await
335-
} else if let (Some(caps), &Method::POST) =
336-
(CREATE_EVENTS_BY_CHANNEL_ID.captures(&path), method)
337-
{
338-
let param = RouteParams(vec![caps
339-
.get(1)
340-
.map_or("".to_string(), |m| m.as_str().to_string())]);
341-
342-
req.extensions_mut().insert(param);
343-
344-
insert_events(req, app).await
345343
} else {
346344
Err(ResponseError::NotFound)
347345
}

0 commit comments

Comments
 (0)