Skip to content

Commit

Permalink
doc: Update doc format SecureMaxSize doc
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Aug 29, 2024
1 parent f7cb9ee commit aa9ba27
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 16 deletions.
11 changes: 6 additions & 5 deletions crates/core/src/conn/acme/cache.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*! Ways to cache account data and certificates.
A default implementation for `AsRef<Path>` (`Sting`, `OsString`, `PathBuf`, ...)
allows the use of a local directory as cache.
Note that the files contain private keys.
*/
//! Ways to cache account data and certificates.
//! A default implementation for `AsRef<Path>` (`Sting`, `OsString`, `PathBuf`, ...)
//! allows the use of a local directory as cache.
//!
//! **Note**: The files contain private keys.

use std::error::Error as StdError;
use std::future::Future;
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/depot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Depot {
}
/// Check is there a value is injected to the depot.
///
/// **Note: This is only check injected value.**
/// **Note**: This is only check injected value.
#[inline]
pub fn contains<T: Any + Send + Sync>(&self) -> bool {
self.map.contains_key(&type_key::<T>())
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/http/body/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use hyper::HeaderMap;
///
/// ## Body Closing
///
/// Note that the request body will always be closed normally when the sender is dropped (meaning
/// **Note**: The request body will always be closed normally when the sender is dropped (meaning
/// that the empty terminating chunk will be sent to the remote). If you desire to close the
/// connection with an incomplete response (e.g. in the case of an error during asynchronous
/// processing), call the [`Sender::abort()`] method to abort the body in an abnormal fashion.
Expand Down
18 changes: 15 additions & 3 deletions crates/core/src/http/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,33 @@ use crate::{async_trait, Depot, Error, FlowCtrl, Handler};

static GLOBAL_SECURE_MAX_SIZE: RwLock<usize> = RwLock::new(64 * 1024);

/// Get global secure max size, default value is 64KB.
/// Get global secure maximum size, default value is 64KB.
///
/// **Note**: The security maximum value is only effective when directly obtaining data
/// from the body. For uploaded files, the files are written to temporary files
/// and the bytes is not directly obtained, so they will not be affected.
pub fn global_secure_max_size() -> usize {
*GLOBAL_SECURE_MAX_SIZE.read()
}

/// Set secure max size globally.
/// Set secure maximum size globally.
///
/// It is recommended to use the [`SecureMaxSize`] middleware to have finer-grained
/// control over [`Request`].
///
/// **Note**: The security maximum value is only effective when directly obtaining data
/// from the body. For uploaded files, the files are written to temporary files
/// and the bytes is not directly obtained, so they will not be affected.
pub fn set_global_secure_max_size(size: usize) {
let mut lock = GLOBAL_SECURE_MAX_SIZE.write();
*lock = size;
}

/// Middleware for set the maximum size of request body.
/// Middleware for set the secure maximum size of request body.
///
/// **Note**: The security maximum value is only effective when directly obtaining data
/// from the body. For uploaded files, the files are written to temporary files
/// and the bytes is not directly obtained, so they will not be affected.
pub struct SecureMaxSize(pub usize);
impl SecureMaxSize {
/// Create a new `SecureMaxSize` instance.
Expand Down
2 changes: 1 addition & 1 deletion crates/extra/src/caching_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use salvo_core::{async_trait, Depot, FlowCtrl, Handler, Request, Response};
///
/// ## Streamed bodies
///
/// Note that this handler does not currently provide an etag trailer for
/// **Note**: This handler does not currently provide an etag trailer for
/// streamed bodies, but may do so in the future.
///
/// ## Strong vs weak comparison
Expand Down
4 changes: 2 additions & 2 deletions crates/extra/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ impl WebSocketUpgrade {
/// in the case the write buffer is filling up due to write errors.
/// The default value is unlimited.
///
/// Note: The write buffer only builds up past [`write_buffer_size`](Self::write_buffer_size)
/// **Note**: The write buffer only builds up past [`write_buffer_size`](Self::write_buffer_size)
/// when writes to the underlying stream are failing. So the **write buffer can not
/// fill up if you are not observing write errors even if not flushing**.
///
/// Note: Should always be at least [`write_buffer_size + 1 message`](Self::write_buffer_size)
/// Should always be at least [`write_buffer_size + 1 message`](Self::write_buffer_size)
/// and probably a little more depending on error handling strategy.
#[inline]
pub fn max_write_buffer_size(mut self, max: usize) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion crates/oapi/docs/derive_to_response.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ _`ToResponse`_ can be used in four different ways to generate OpenAPI response c

4. By decorating `enum` with variants having `#[salvo(content(...))]` attribute. This allows users to
define multiple response content schemas to single response according to OpenAPI spec.
**Note!** Enum with _`content`_ attribute in variants cannot have enum level _`example`_ or
**Note**: Enum with _`content`_ attribute in variants cannot have enum level _`example`_ or
_`examples`_ defined. Instead examples need to be defined per variant basis. Additionally
these variants can also be used with `#[salvo(schema(...))]` attribute to inline the variant's type schema
if it implements [`ToSchema`] derive macro.
Expand Down
2 changes: 1 addition & 1 deletion crates/oapi/docs/derive_to_schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ enum representation](https://serde.rs/enum-representations.html#untagged).

Other _`serde`_ attributes works as is but does not have any effect on the generated OpenAPI doc.

**Note!** `tag` attribute has some limitations like it cannot be used
**Note**: `tag` attribute has some limitations like it cannot be used
with **unnamed field structs** and **tuple types**. See more at
[enum representation docs](https://serde.rs/enum-representations.html).

Expand Down
2 changes: 1 addition & 1 deletion crates/oapi/src/swagger_ui/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ impl<'a> Config<'a> {
/// Set `with_credentials` to enable passing credentials to CORS requests send by browser as defined
/// [fetch standards](https://fetch.spec.whatwg.org/#credentials).
///
/// **Note!** that Swagger UI cannot currently set cookies cross-domain
/// **Note**: that Swagger UI cannot currently set cookies cross-domain
/// (see [swagger-js#1163](https://github.com/swagger-api/swagger-js/issues/1163)) -
/// as a result, you will have to rely on browser-supplied cookies (which this setting enables sending)
/// that Swagger UI cannot control.
Expand Down

0 comments on commit aa9ba27

Please sign in to comment.