"Turn on" serde

This commit is contained in:
Yong Wen Chua 2017-07-15 11:56:00 +08:00
parent 2fa82cea69
commit eda194c451
2 changed files with 11 additions and 8 deletions

View File

@ -12,7 +12,10 @@ use unicase::UniCase;
use url; use url;
use url_serde; use url_serde;
/// A case insensitive header name
pub(crate) type HeaderFieldName = UniCase<String>; pub(crate) type HeaderFieldName = UniCase<String>;
/// A set of case insensitive header names
pub(crate) type HeaderFieldNamesSet = HashSet<HeaderFieldName>; pub(crate) type HeaderFieldNamesSet = HashSet<HeaderFieldName>;
/// A wrapped `url::Url` to allow for deserialization /// A wrapped `url::Url` to allow for deserialization

View File

@ -342,7 +342,7 @@ impl<'de> Deserialize<'de> for Method {
/// ///
/// [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html) is implemented for this /// [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html) is implemented for this
/// struct. The default for each field is described in the docuementation for the field. /// struct. The default for each field is described in the docuementation for the field.
#[derive(Clone, Debug)] #[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Cors { pub struct Cors {
/// Origins that are allowed to make requests. /// Origins that are allowed to make requests.
/// Will be verified against the `Origin` request header. /// Will be verified against the `Origin` request header.
@ -360,7 +360,7 @@ pub struct Cors {
/// Defaults to `All`. /// Defaults to `All`.
/// ///
/// ``` /// ```
// #[serde(default)] #[serde(default)]
pub allowed_origins: AllOrSome<HashSet<Url>>, pub allowed_origins: AllOrSome<HashSet<Url>>,
/// The list of methods which the allowed origins are allowed to access for /// The list of methods which the allowed origins are allowed to access for
/// non-simple requests. /// non-simple requests.
@ -369,7 +369,7 @@ pub struct Cors {
/// [Resource Processing Model](https://www.w3.org/TR/cors/#resource-processing-model). /// [Resource Processing Model](https://www.w3.org/TR/cors/#resource-processing-model).
/// ///
/// Defaults to `[GET, HEAD, POST, OPTIONS, PUT, PATCH, DELETE]` /// Defaults to `[GET, HEAD, POST, OPTIONS, PUT, PATCH, DELETE]`
// #[serde(default = "Cors::default_allowed_methods")] #[serde(default = "Cors::default_allowed_methods")]
pub allowed_methods: HashSet<Method>, pub allowed_methods: HashSet<Method>,
/// The list of header field names which can be used when this resource is accessed by allowed /// The list of header field names which can be used when this resource is accessed by allowed
/// origins. /// origins.
@ -381,7 +381,7 @@ pub struct Cors {
/// [Resource Processing Model](https://www.w3.org/TR/cors/#resource-processing-model). /// [Resource Processing Model](https://www.w3.org/TR/cors/#resource-processing-model).
/// ///
/// Defaults to `All`. /// Defaults to `All`.
// #[serde(default)] #[serde(default)]
pub allowed_headers: AllOrSome<HashSet<HeaderFieldName>>, pub allowed_headers: AllOrSome<HashSet<HeaderFieldName>>,
/// Allows users to make authenticated requests. /// Allows users to make authenticated requests.
/// If true, injects the `Access-Control-Allow-Credentials` header in responses. /// If true, injects the `Access-Control-Allow-Credentials` header in responses.
@ -392,7 +392,7 @@ pub struct Cors {
/// in an `Error::CredentialsWithWildcardOrigin` error during Rocket launch or runtime. /// in an `Error::CredentialsWithWildcardOrigin` error during Rocket launch or runtime.
/// ///
/// Defaults to `false`. /// Defaults to `false`.
// #[serde(default)] #[serde(default)]
pub allow_credentials: bool, pub allow_credentials: bool,
/// The list of headers which are safe to expose to the API of a CORS API specification. /// The list of headers which are safe to expose to the API of a CORS API specification.
/// This corresponds to the `Access-Control-Expose-Headers` responde header. /// This corresponds to the `Access-Control-Expose-Headers` responde header.
@ -401,13 +401,13 @@ pub struct Cors {
/// [Resource Processing Model](https://www.w3.org/TR/cors/#resource-processing-model). /// [Resource Processing Model](https://www.w3.org/TR/cors/#resource-processing-model).
/// ///
/// This defaults to an empty set. /// This defaults to an empty set.
// #[serde(default)] #[serde(default)]
pub expose_headers: HashSet<String>, pub expose_headers: HashSet<String>,
/// The maximum time for which this CORS request maybe cached. This value is set as the /// The maximum time for which this CORS request maybe cached. This value is set as the
/// `Access-Control-Max-Age` header. /// `Access-Control-Max-Age` header.
/// ///
/// This defaults to `None` (unset). /// This defaults to `None` (unset).
// #[serde(default)] #[serde(default)]
pub max_age: Option<usize>, pub max_age: Option<usize>,
/// If true, and the `allowed_origins` parameter is `All`, a wildcard /// If true, and the `allowed_origins` parameter is `All`, a wildcard
/// `Access-Control-Allow-Origin` response header is sent, rather than the requests /// `Access-Control-Allow-Origin` response header is sent, rather than the requests
@ -421,7 +421,7 @@ pub struct Cors {
/// in an `Error::CredentialsWithWildcardOrigin` error during Rocket launch or runtime. /// in an `Error::CredentialsWithWildcardOrigin` error during Rocket launch or runtime.
/// ///
/// Defaults to `false`. /// Defaults to `false`.
// #[serde(default)] #[serde(default)]
pub send_wildcard: bool, pub send_wildcard: bool,
} }