Make json an optional feature (default off)

This commit is contained in:
Constantin Nickel
2019-09-27 16:09:25 +02:00
committed by Sean McArthur
parent a787fc1b38
commit 24394364eb
10 changed files with 59 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ use std::future::Future;
use base64::encode;
use serde::Serialize;
#[cfg(feature = "json")]
use serde_json;
use serde_urlencoded;
@@ -287,10 +288,15 @@ impl RequestBuilder {
/// Send a JSON body.
///
/// # Optional
///
/// This requires the optional `json` feature enabled.
///
/// # Errors
///
/// Serialization can fail if `T`'s implementation of `Serialize` decides to
/// fail, or if `T` contains a map with non-string keys.
#[cfg(feature = "json")]
pub fn json<T: Serialize + ?Sized>(mut self, json: &T) -> RequestBuilder {
let mut error = None;
if let Ok(ref mut req) = self.request {