mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-02-22 20:52:27 +00:00
doctest fix #26
This commit is contained in:
parent
604494651d
commit
4ff5a8d7e4
3 changed files with 15 additions and 7 deletions
12
src/lib.rs
12
src/lib.rs
|
@ -43,7 +43,7 @@ struct FooResource;
|
|||
|
||||
/// The return type of the foo read method.
|
||||
#[derive(Serialize)]
|
||||
# #[derive(OpenapiType)]
|
||||
# #[cfg_attr(feature = "openapi", derive(OpenapiType))]
|
||||
struct Foo {
|
||||
id: u64
|
||||
}
|
||||
|
@ -123,6 +123,8 @@ None of this is currently supported by gotham's own JWT middleware.
|
|||
A simple example that uses only a single secret could look like this:
|
||||
|
||||
```rust,no_run
|
||||
# #[cfg(feature = "auth")]
|
||||
# mod auth_feature_enabled {
|
||||
# #[macro_use] extern crate gotham_restful_derive;
|
||||
# use gotham::{router::builder::*, pipeline::{new_pipeline, single::single_pipeline}, state::State};
|
||||
# use gotham_restful::*;
|
||||
|
@ -132,7 +134,7 @@ A simple example that uses only a single secret could look like this:
|
|||
struct SecretResource;
|
||||
|
||||
#[derive(Serialize)]
|
||||
# #[derive(OpenapiType)]
|
||||
# #[cfg_attr(feature = "openapi", derive(OpenapiType))]
|
||||
struct Secret {
|
||||
id: u64,
|
||||
intended_for: String
|
||||
|
@ -161,6 +163,7 @@ fn main() {
|
|||
route.resource::<SecretResource>("secret");
|
||||
}));
|
||||
}
|
||||
# }
|
||||
```
|
||||
|
||||
## Database Feature
|
||||
|
@ -173,6 +176,8 @@ you'll need to borrow the connection from the [`State`] yourself and return a bo
|
|||
A simple non-async example could look like this:
|
||||
|
||||
```rust,no_run
|
||||
# #[cfg(feature = "database")]
|
||||
# mod database_feature_enabled {
|
||||
# #[macro_use] extern crate diesel;
|
||||
# #[macro_use] extern crate gotham_restful_derive;
|
||||
# use diesel::{table, PgConnection, QueryResult, RunQueryDsl};
|
||||
|
@ -192,7 +197,7 @@ A simple non-async example could look like this:
|
|||
struct FooResource;
|
||||
|
||||
#[derive(Queryable, Serialize)]
|
||||
# #[derive(OpenapiType)]
|
||||
# #[cfg_attr(feature = "openapi", derive(OpenapiType))]
|
||||
struct Foo {
|
||||
id: i64,
|
||||
value: String
|
||||
|
@ -214,6 +219,7 @@ fn main() {
|
|||
route.resource::<FooResource>("foo");
|
||||
}));
|
||||
}
|
||||
# }
|
||||
```
|
||||
|
||||
# Examples
|
||||
|
|
|
@ -21,9 +21,10 @@ This return type can be used to map another `ResourceResult` that can only be re
|
|||
client is authenticated. Otherwise, an empty _403 Forbidden_ response will be issued. Use can
|
||||
look something like this (assuming the `auth` feature is enabled):
|
||||
|
||||
```
|
||||
```rust
|
||||
# #[cfg(feature = "auth")]
|
||||
# mod auth_feature_enabled {
|
||||
# #[macro_use] extern crate gotham_restful_derive;
|
||||
# mod doc_tests_are_broken {
|
||||
# use gotham::state::State;
|
||||
# use gotham_restful::*;
|
||||
# use serde::Deserialize;
|
||||
|
@ -81,8 +82,9 @@ client is authenticated. Otherwise, an empty _403 Forbidden_ response will be is
|
|||
look something like this (assuming the `auth` feature is enabled):
|
||||
|
||||
```
|
||||
# #[cfg(feature = "auth")]
|
||||
# mod auth_feature_enabled {
|
||||
# #[macro_use] extern crate gotham_restful_derive;
|
||||
# mod doc_tests_are_broken {
|
||||
# use gotham::state::State;
|
||||
# use gotham_restful::*;
|
||||
# use serde::Deserialize;
|
||||
|
|
|
@ -29,7 +29,7 @@ Usage example:
|
|||
# struct MyResource;
|
||||
#
|
||||
#[derive(Deserialize, Serialize)]
|
||||
# #[derive(OpenapiType)]
|
||||
# #[cfg_attr(feature = "openapi", derive(OpenapiType))]
|
||||
struct MyResponse {
|
||||
message: &'static str
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue