Skip to content

Commit 84f8d36

Browse files
authored
feat: Support for curl and disabled transports (#124)
1 parent 0c83274 commit 84f8d36

File tree

5 files changed

+322
-132
lines changed

5 files changed

+322
-132
lines changed

Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ autoexamples = true
1818
all-features = true
1919

2020
[features]
21-
default = ["with_client_implementation", "with_panic", "with_failure", "with_log", "with_env_logger", "with_device_info", "with_rust_info"]
22-
with_client_implementation = ["reqwest", "im", "url", "with_backtrace"]
21+
default = ["with_client_implementation", "with_default_transport", "with_panic", "with_failure", "with_log", "with_env_logger", "with_device_info", "with_rust_info"]
22+
with_reqwest_transport = ["reqwest", "httpdate", "with_client_implementation"]
23+
with_curl_transport = ["curl", "httpdate", "serde_json", "with_client_implementation"]
24+
with_default_transport = ["with_reqwest_transport"]
25+
with_client_implementation = ["im", "url", "with_backtrace"]
2326
with_backtrace = ["backtrace", "regex"]
2427
with_panic = ["with_backtrace"]
2528
with_failure = ["failure", "with_backtrace"]
@@ -48,7 +51,9 @@ libc = { version = "0.2.48", optional = true }
4851
hostname = { version = "0.1.5", optional = true }
4952
findshlibs = { version = "0.4.1", optional = true }
5053
rand = "0.6.5"
51-
httpdate = "0.3.2"
54+
httpdate = { version = "0.3.2", optional = true }
55+
curl = { version = "0.4.19", optional = true }
56+
serde_json = { version = "1.0.38", optional = true }
5257

5358
[target."cfg(not(windows))".dependencies]
5459
uname = { version = "0.1.1", optional = true }

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ check-all-impls:
5353
@RUSTFLAGS=-Dwarnings cargo check --no-default-features --features 'with_failure,with_log,with_panic,with_error_chain'
5454
.PHONY: check-all-impls
5555

56+
check-curl-transport:
57+
@echo 'CURL TRANSPORT'
58+
@RUSTFLAGS=-Dwarnings cargo check --features with_curl_transport
59+
@echo 'CURL TRANSPORT ONLY'
60+
@RUSTFLAGS=-Dwarnings cargo check --no-default-features --features 'with_curl_transport,with_client_implementation,with_panic'
61+
.PHONY: check-curl-transport
62+
5663
check-actix:
5764
@echo 'ACTIX INTEGRATION'
5865
@RUSTFLAGS=-Dwarnings cargo check --manifest-path integrations/sentry-actix/Cargo.toml
@@ -61,7 +68,7 @@ check-actix:
6168
check: check-no-default-features check-default-features
6269
.PHONY: check-all-features
6370

64-
checkall: check-all-features check-no-default-features check-default-features check-failure check-log check-panic check-error-chain check-all-impls check-actix
71+
checkall: check-all-features check-no-default-features check-default-features check-failure check-log check-panic check-error-chain check-all-impls check-curl-transport check-actix
6572
.PHONY: checkall
6673

6774
cargotest:

src/lib.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
//! default flags:
9090
//!
9191
//! * `with_client_implementation`: turns on the real client implementation.
92+
//! * `with_default_transport`: compiles in the default HTTP transport.
9293
//! * `with_backtrace`: enables backtrace support (automatically turned on in a few cases)
9394
//! * `with_panic`: enables the panic integration
9495
//! * `with_failure`: enables the `failure` integration
@@ -104,6 +105,9 @@
104105
//!
105106
//! * `with_error_chain`: enables the error-chain integration
106107
//! * `with_test_support`: enables the test support module
108+
//! * `with_reqwest_transport`: enables the reqwest transport explicitly. This
109+
//! is currently the default transport.
110+
//! * `with_curl_transport`: enables the curl transport.
107111
#![warn(missing_docs)]
108112

109113
#[macro_use]
@@ -142,7 +146,7 @@ pub mod internals {
142146
#[cfg(feature = "with_client_implementation")]
143147
pub use crate::{
144148
client::{ClientInitGuard, IntoDsn},
145-
transport::{DefaultTransportFactory, HttpTransport, Transport, TransportFactory},
149+
transport::{Transport, TransportFactory},
146150
};
147151

148152
pub use sentry_types::{
@@ -151,6 +155,22 @@ pub mod internals {
151155
};
152156
}
153157

158+
/// The provided transports.
159+
///
160+
/// This module exposes all transports that are compiled into the sentry
161+
/// library. The `with_reqwest_transport` and `with_curl_transport` flags
162+
/// turn on these transports.
163+
pub mod transports {
164+
#[cfg(any(feature = "with_reqwest_transport", feature = "with_curl_transport"))]
165+
pub use crate::transport::{DefaultTransportFactory, HttpTransport};
166+
167+
#[cfg(feature = "with_reqwest_transport")]
168+
pub use crate::transport::ReqwestHttpTransport;
169+
170+
#[cfg(feature = "with_curl_transport")]
171+
pub use crate::transport::CurlHttpTransport;
172+
}
173+
154174
// public api or exports from this crate
155175
pub use crate::api::*;
156176
pub use crate::hub::Hub;

0 commit comments

Comments
 (0)