Make contrib MsgPack tests actually run.

This commit is contained in:
Sergio Benitez 2018-07-10 17:08:58 -07:00
parent 0045486227
commit 5acb08a026
1 changed files with 29 additions and 12 deletions

View File

@ -26,20 +26,28 @@ pub use self::rmp_serde::decode::Error as MsgPackError;
/// [Serde](https://github.com/serde-rs/serde). The data is parsed from the HTTP /// [Serde](https://github.com/serde-rs/serde). The data is parsed from the HTTP
/// request body. /// request body.
/// ///
/// ```rust,ignore /// ```rust
/// #[post("/users/", format = "application/msgpack", data = "<user>")] /// # #![feature(plugin, decl_macro)]
/// # #![plugin(rocket_codegen)]
/// # extern crate rocket;
/// # extern crate rocket_contrib;
/// # type User = usize;
/// # fn main() { }
/// #
/// use rocket_contrib::MsgPack;
///
/// #[post("/users", format = "msgpack", data = "<user>")]
/// fn new_user(user: MsgPack<User>) { /// fn new_user(user: MsgPack<User>) {
/// ... /// /* ... */
/// } /// }
/// ``` /// ```
/// ///
/// You don't _need_ to use `format = "application/msgpack"`, but it _may_ be /// You don't _need_ to use `format = "msgpack"`, but it _may_ be what you want.
/// what you want. Using `format = application/msgpack` means that any request /// Using `format = msgpack` means that any request that doesn't specify
/// that doesn't specify "application/msgpack" as its first `Content-Type:` /// "application/msgpack" as its first `Content-Type:` header parameter will not
/// header parameter will not be routed to this handler. By default, Rocket will /// be routed to this handler. By default, Rocket will accept a Content-Type of
/// accept a Content Type of any of the following for MessagePack data: /// any of the following for MessagePack data: `application/msgpack`,
/// `application/msgpack`, `application/x-msgpack`, `bin/msgpack`, or /// `application/x-msgpack`, `bin/msgpack`, or `bin/x-msgpack`.
/// `bin/x-msgpack`.
/// ///
/// ## Sending MessagePack /// ## Sending MessagePack
/// ///
@ -48,11 +56,20 @@ pub use self::rmp_serde::decode::Error as MsgPackError;
/// [Serde](https://github.com/serde-rs/serde). The content type of the response /// [Serde](https://github.com/serde-rs/serde). The content type of the response
/// is set to `application/msgpack` automatically. /// is set to `application/msgpack` automatically.
/// ///
/// ```rust,ignore /// ```rust
/// # #![feature(plugin, decl_macro)]
/// # #![plugin(rocket_codegen)]
/// # extern crate rocket;
/// # extern crate rocket_contrib;
/// # type User = usize;
/// # fn main() { }
/// #
/// use rocket_contrib::MsgPack;
///
/// #[get("/users/<id>")] /// #[get("/users/<id>")]
/// fn user(id: usize) -> MsgPack<User> { /// fn user(id: usize) -> MsgPack<User> {
/// let user_from_id = User::from(id); /// let user_from_id = User::from(id);
/// ... /// /* ... */
/// MsgPack(user_from_id) /// MsgPack(user_from_id)
/// } /// }
/// ``` /// ```