mirror of
https://github.com/poem-web/poem.git
synced 2026-01-25 04:18:25 +00:00
clippy
This commit is contained in:
@@ -2,7 +2,7 @@ edition = "2021"
|
|||||||
newline_style = "unix"
|
newline_style = "unix"
|
||||||
# comments
|
# comments
|
||||||
normalize_comments = true
|
normalize_comments = true
|
||||||
#wrap_comments=true
|
wrap_comments = true
|
||||||
format_code_in_doc_comments = true
|
format_code_in_doc_comments = true
|
||||||
# imports
|
# imports
|
||||||
imports_granularity = "Crate"
|
imports_granularity = "Crate"
|
||||||
|
|||||||
@@ -40,14 +40,14 @@ impl<'a, T: Codec> GrpcServer<'a, T> {
|
|||||||
{
|
{
|
||||||
let (parts, body) = request.into_parts();
|
let (parts, body) = request.into_parts();
|
||||||
let mut resp = Response::default().set_content_type(T::CONTENT_TYPES[0]);
|
let mut resp = Response::default().set_content_type(T::CONTENT_TYPES[0]);
|
||||||
let incoming_encoding =
|
let incoming_encoding = match get_incoming_encodings(&parts.headers, self.accept_compressed)
|
||||||
match get_incoming_encodings(&parts.headers, &self.accept_compressed) {
|
{
|
||||||
Ok(incoming_encoding) => incoming_encoding,
|
Ok(incoming_encoding) => incoming_encoding,
|
||||||
Err(status) => {
|
Err(status) => {
|
||||||
resp.headers_mut().extend(status.to_headers());
|
resp.headers_mut().extend(status.to_headers());
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let mut stream = create_decode_request_body(self.codec.decoder(), body, incoming_encoding);
|
let mut stream = create_decode_request_body(self.codec.decoder(), body, incoming_encoding);
|
||||||
|
|
||||||
let res = match stream.next().await {
|
let res = match stream.next().await {
|
||||||
@@ -88,14 +88,14 @@ impl<'a, T: Codec> GrpcServer<'a, T> {
|
|||||||
{
|
{
|
||||||
let (parts, body) = request.into_parts();
|
let (parts, body) = request.into_parts();
|
||||||
let mut resp = Response::default().set_content_type(T::CONTENT_TYPES[0]);
|
let mut resp = Response::default().set_content_type(T::CONTENT_TYPES[0]);
|
||||||
let incoming_encoding =
|
let incoming_encoding = match get_incoming_encodings(&parts.headers, self.accept_compressed)
|
||||||
match get_incoming_encodings(&parts.headers, &self.accept_compressed) {
|
{
|
||||||
Ok(incoming_encoding) => incoming_encoding,
|
Ok(incoming_encoding) => incoming_encoding,
|
||||||
Err(status) => {
|
Err(status) => {
|
||||||
resp.headers_mut().extend(status.to_headers());
|
resp.headers_mut().extend(status.to_headers());
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let stream = create_decode_request_body(self.codec.decoder(), body, incoming_encoding);
|
let stream = create_decode_request_body(self.codec.decoder(), body, incoming_encoding);
|
||||||
|
|
||||||
let res = service
|
let res = service
|
||||||
@@ -132,14 +132,14 @@ impl<'a, T: Codec> GrpcServer<'a, T> {
|
|||||||
{
|
{
|
||||||
let (parts, body) = request.into_parts();
|
let (parts, body) = request.into_parts();
|
||||||
let mut resp = Response::default().set_content_type(T::CONTENT_TYPES[0]);
|
let mut resp = Response::default().set_content_type(T::CONTENT_TYPES[0]);
|
||||||
let incoming_encoding =
|
let incoming_encoding = match get_incoming_encodings(&parts.headers, self.accept_compressed)
|
||||||
match get_incoming_encodings(&parts.headers, &self.accept_compressed) {
|
{
|
||||||
Ok(incoming_encoding) => incoming_encoding,
|
Ok(incoming_encoding) => incoming_encoding,
|
||||||
Err(status) => {
|
Err(status) => {
|
||||||
resp.headers_mut().extend(status.to_headers());
|
resp.headers_mut().extend(status.to_headers());
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let mut stream = create_decode_request_body(self.codec.decoder(), body, incoming_encoding);
|
let mut stream = create_decode_request_body(self.codec.decoder(), body, incoming_encoding);
|
||||||
|
|
||||||
let res = match stream.next().await {
|
let res = match stream.next().await {
|
||||||
@@ -179,14 +179,14 @@ impl<'a, T: Codec> GrpcServer<'a, T> {
|
|||||||
{
|
{
|
||||||
let (parts, body) = request.into_parts();
|
let (parts, body) = request.into_parts();
|
||||||
let mut resp = Response::default().set_content_type(T::CONTENT_TYPES[0]);
|
let mut resp = Response::default().set_content_type(T::CONTENT_TYPES[0]);
|
||||||
let incoming_encoding =
|
let incoming_encoding = match get_incoming_encodings(&parts.headers, self.accept_compressed)
|
||||||
match get_incoming_encodings(&parts.headers, &self.accept_compressed) {
|
{
|
||||||
Ok(incoming_encoding) => incoming_encoding,
|
Ok(incoming_encoding) => incoming_encoding,
|
||||||
Err(status) => {
|
Err(status) => {
|
||||||
resp.headers_mut().extend(status.to_headers());
|
resp.headers_mut().extend(status.to_headers());
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let stream = create_decode_request_body(self.codec.decoder(), body, incoming_encoding);
|
let stream = create_decode_request_body(self.codec.decoder(), body, incoming_encoding);
|
||||||
|
|
||||||
let res = service
|
let res = service
|
||||||
|
|||||||
@@ -95,65 +95,65 @@ impl<T> Default for ExtractParamOptions<T> {
|
|||||||
/// - **Path<T: Type>**
|
/// - **Path<T: Type>**
|
||||||
///
|
///
|
||||||
/// Extract the parameters in the request path into
|
/// Extract the parameters in the request path into
|
||||||
/// [`Path`](crate::param::Path).
|
/// [`Path`](crate::param::Path).
|
||||||
///
|
///
|
||||||
/// - **Query<T: Type>**
|
/// - **Query<T: Type>**
|
||||||
///
|
///
|
||||||
/// Extract the parameters in the query string into
|
/// Extract the parameters in the query string into
|
||||||
/// [`Query`](crate::param::Query).
|
/// [`Query`](crate::param::Query).
|
||||||
///
|
///
|
||||||
/// - **Header<T: Type>**
|
/// - **Header<T: Type>**
|
||||||
///
|
///
|
||||||
/// Extract the parameters in the request header into
|
/// Extract the parameters in the request header into
|
||||||
/// [`Header`](crate::param::Header).
|
/// [`Header`](crate::param::Header).
|
||||||
///
|
///
|
||||||
/// - **Cookie<T: Type>**
|
/// - **Cookie<T: Type>**
|
||||||
///
|
///
|
||||||
/// Extract the parameters in the cookie into
|
/// Extract the parameters in the cookie into
|
||||||
/// [`Cookie`](crate::param::Cookie).
|
/// [`Cookie`](crate::param::Cookie).
|
||||||
///
|
///
|
||||||
/// - **CookiePrivate<T: Type>**
|
/// - **CookiePrivate<T: Type>**
|
||||||
///
|
///
|
||||||
/// Extract the parameters in the private cookie into
|
/// Extract the parameters in the private cookie into
|
||||||
/// [`CookiePrivate`](crate::param::CookiePrivate).
|
/// [`CookiePrivate`](crate::param::CookiePrivate).
|
||||||
///
|
///
|
||||||
/// - **CookieSigned<T: Type>**
|
/// - **CookieSigned<T: Type>**
|
||||||
///
|
///
|
||||||
/// Extract the parameters in the signed cookie into
|
/// Extract the parameters in the signed cookie into
|
||||||
/// [`CookieSigned`](crate::param::CookieSigned).
|
/// [`CookieSigned`](crate::param::CookieSigned).
|
||||||
///
|
///
|
||||||
/// - **Binary<T>**
|
/// - **Binary<T>**
|
||||||
///
|
///
|
||||||
/// Extract the request body as binary into
|
/// Extract the request body as binary into
|
||||||
/// [`Binary`](crate::payload::Binary).
|
/// [`Binary`](crate::payload::Binary).
|
||||||
///
|
///
|
||||||
/// - **Json<T>**
|
/// - **Json<T>**
|
||||||
///
|
///
|
||||||
/// Parse the request body in `JSON` format into
|
/// Parse the request body in `JSON` format into
|
||||||
/// [`Json`](crate::payload::Json).
|
/// [`Json`](crate::payload::Json).
|
||||||
///
|
///
|
||||||
/// - **PlainText<T>**
|
/// - **PlainText<T>**
|
||||||
///
|
///
|
||||||
/// Extract the request body as utf8 string into
|
/// Extract the request body as utf8 string into
|
||||||
/// [`PlainText`](crate::payload::PlainText).
|
/// [`PlainText`](crate::payload::PlainText).
|
||||||
///
|
///
|
||||||
/// - **Any type derived from the [`ApiRequest`](crate::ApiRequest) macro**
|
/// - **Any type derived from the [`ApiRequest`](crate::ApiRequest) macro**
|
||||||
///
|
///
|
||||||
/// Extract the complex request body derived from the `ApiRequest` macro.
|
/// Extract the complex request body derived from the `ApiRequest` macro.
|
||||||
///
|
///
|
||||||
/// - **Any type derived from the [`Multipart`](crate::Multipart) macro**
|
/// - **Any type derived from the [`Multipart`](crate::Multipart) macro**
|
||||||
///
|
///
|
||||||
/// Extract the multipart object derived from the `Multipart` macro.
|
/// Extract the multipart object derived from the `Multipart` macro.
|
||||||
///
|
///
|
||||||
/// - **Any type derived from the [`SecurityScheme`](crate::SecurityScheme)
|
/// - **Any type derived from the [`SecurityScheme`](crate::SecurityScheme)
|
||||||
/// macro**
|
/// macro**
|
||||||
///
|
///
|
||||||
/// Extract the authentication value derived from the `SecurityScheme`
|
/// Extract the authentication value derived from the `SecurityScheme`
|
||||||
/// macro.
|
/// macro.
|
||||||
///
|
///
|
||||||
/// - **T: poem::FromRequest**
|
/// - **T: poem::FromRequest**
|
||||||
///
|
///
|
||||||
/// Use Poem's extractor.
|
/// Use Poem's extractor.
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
pub trait ApiExtractor<'a>: Sized {
|
pub trait ApiExtractor<'a>: Sized {
|
||||||
/// The type of API extractor.
|
/// The type of API extractor.
|
||||||
@@ -250,24 +250,24 @@ impl<T: Payload> ResponseContent for T {
|
|||||||
///
|
///
|
||||||
/// - **Binary<T: Type>**
|
/// - **Binary<T: Type>**
|
||||||
///
|
///
|
||||||
/// A binary response with content type `application/octet-stream`.
|
/// A binary response with content type `application/octet-stream`.
|
||||||
///
|
///
|
||||||
/// - **Json<T: Type>**
|
/// - **Json<T: Type>**
|
||||||
///
|
///
|
||||||
/// A JSON response with content type `application/json`.
|
/// A JSON response with content type `application/json`.
|
||||||
///
|
///
|
||||||
/// - **PlainText<T: Type>**
|
/// - **PlainText<T: Type>**
|
||||||
///
|
///
|
||||||
/// A utf8 string response with content type `text/plain`.
|
/// A utf8 string response with content type `text/plain`.
|
||||||
///
|
///
|
||||||
/// - **Attachment<T: Type>**
|
/// - **Attachment<T: Type>**
|
||||||
///
|
///
|
||||||
/// A file download response, the content type is
|
/// A file download response, the content type is
|
||||||
/// `application/octet-stream`.
|
/// `application/octet-stream`.
|
||||||
///
|
///
|
||||||
/// - **Response<T: Type>**
|
/// - **Response<T: Type>**
|
||||||
///
|
///
|
||||||
/// A response type use it to modify the status code and HTTP headers.
|
/// A response type use it to modify the status code and HTTP headers.
|
||||||
///
|
///
|
||||||
/// - **()**
|
/// - **()**
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -953,6 +953,7 @@ async fn hidden() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_405() {
|
fn issue_405() {
|
||||||
|
#[allow(dead_code)]
|
||||||
struct Api;
|
struct Api;
|
||||||
|
|
||||||
#[OpenApi]
|
#[OpenApi]
|
||||||
@@ -963,11 +964,13 @@ fn issue_405() {
|
|||||||
operation_id = "hello",
|
operation_id = "hello",
|
||||||
transform = "my_transformer"
|
transform = "my_transformer"
|
||||||
)]
|
)]
|
||||||
|
#[allow(dead_code)]
|
||||||
async fn index(&self) -> PlainText<String> {
|
async fn index(&self) -> PlainText<String> {
|
||||||
PlainText("hello, world!".to_string())
|
PlainText("hello, world!".to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn my_transformer(ep: impl Endpoint) -> impl Endpoint {
|
fn my_transformer(ep: impl Endpoint) -> impl Endpoint {
|
||||||
ep.map_to_response()
|
ep.map_to_response()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use poem_openapi::{
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn name() {
|
async fn name() {
|
||||||
#[Webhook]
|
#[Webhook]
|
||||||
|
#[allow(dead_code)]
|
||||||
trait MyWebhooks {
|
trait MyWebhooks {
|
||||||
#[oai(name = "a", method = "post")]
|
#[oai(name = "a", method = "post")]
|
||||||
fn test1(&self);
|
fn test1(&self);
|
||||||
@@ -28,6 +29,7 @@ async fn name() {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn method() {
|
async fn method() {
|
||||||
#[Webhook]
|
#[Webhook]
|
||||||
|
#[allow(dead_code)]
|
||||||
trait MyWebhooks {
|
trait MyWebhooks {
|
||||||
#[oai(method = "post")]
|
#[oai(method = "post")]
|
||||||
fn test1(&self);
|
fn test1(&self);
|
||||||
@@ -43,6 +45,7 @@ async fn method() {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn deprecated() {
|
async fn deprecated() {
|
||||||
#[Webhook]
|
#[Webhook]
|
||||||
|
#[allow(dead_code)]
|
||||||
trait MyWebhooks {
|
trait MyWebhooks {
|
||||||
#[oai(method = "post")]
|
#[oai(method = "post")]
|
||||||
fn test1(&self);
|
fn test1(&self);
|
||||||
@@ -65,6 +68,7 @@ async fn tags() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Webhook(tag = "MyTags::A")]
|
#[Webhook(tag = "MyTags::A")]
|
||||||
|
#[allow(dead_code)]
|
||||||
trait MyWebhooks: Sync {
|
trait MyWebhooks: Sync {
|
||||||
#[oai(method = "post", tag = "MyTags::B", tag = "MyTags::C")]
|
#[oai(method = "post", tag = "MyTags::B", tag = "MyTags::C")]
|
||||||
fn test1(&self);
|
fn test1(&self);
|
||||||
@@ -83,6 +87,7 @@ async fn tags() {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn operation_id() {
|
async fn operation_id() {
|
||||||
#[Webhook]
|
#[Webhook]
|
||||||
|
#[allow(dead_code)]
|
||||||
trait MyWebhooks {
|
trait MyWebhooks {
|
||||||
#[oai(method = "post", operation_id = "a")]
|
#[oai(method = "post", operation_id = "a")]
|
||||||
fn test1(&self);
|
fn test1(&self);
|
||||||
@@ -104,6 +109,7 @@ async fn operation_id() {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn parameters() {
|
async fn parameters() {
|
||||||
#[Webhook]
|
#[Webhook]
|
||||||
|
#[allow(dead_code)]
|
||||||
trait MyWebhooks {
|
trait MyWebhooks {
|
||||||
#[oai(method = "post")]
|
#[oai(method = "post")]
|
||||||
fn test(&self, a: Query<i32>, b: Path<String>);
|
fn test(&self, a: Query<i32>, b: Path<String>);
|
||||||
@@ -139,6 +145,7 @@ async fn request_body() {
|
|||||||
#[Webhook]
|
#[Webhook]
|
||||||
trait MyWebhooks {
|
trait MyWebhooks {
|
||||||
#[oai(method = "post")]
|
#[oai(method = "post")]
|
||||||
|
#[allow(dead_code)]
|
||||||
fn test(&self, req: Json<i32>);
|
fn test(&self, req: Json<i32>);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +167,7 @@ async fn response() {
|
|||||||
#[Webhook]
|
#[Webhook]
|
||||||
trait MyWebhooks {
|
trait MyWebhooks {
|
||||||
#[oai(method = "post")]
|
#[oai(method = "post")]
|
||||||
|
#[allow(dead_code)]
|
||||||
fn test(&self) -> Json<i32>;
|
fn test(&self) -> Json<i32>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +192,7 @@ async fn create() {
|
|||||||
#[Webhook]
|
#[Webhook]
|
||||||
trait MyWebhooks {
|
trait MyWebhooks {
|
||||||
#[oai(method = "post")]
|
#[oai(method = "post")]
|
||||||
|
#[allow(dead_code)]
|
||||||
fn test(&self) -> Json<i32>;
|
fn test(&self) -> Json<i32>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,6 +207,7 @@ async fn external_docs() {
|
|||||||
method = "post",
|
method = "post",
|
||||||
external_docs = "https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md"
|
external_docs = "https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md"
|
||||||
)]
|
)]
|
||||||
|
#[allow(dead_code)]
|
||||||
fn test(&self);
|
fn test(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,8 +117,7 @@ impl RequestBody {
|
|||||||
///
|
///
|
||||||
/// - **Option<T>**
|
/// - **Option<T>**
|
||||||
///
|
///
|
||||||
/// Extracts `T` from the incoming request, returns [`None`] if it
|
/// Extracts `T` from the incoming request, returns [`None`] if it fails.
|
||||||
/// fails.
|
|
||||||
///
|
///
|
||||||
/// - **&Request**
|
/// - **&Request**
|
||||||
///
|
///
|
||||||
@@ -177,28 +176,28 @@ impl RequestBody {
|
|||||||
/// Extracts the [`Json`] from the incoming request.
|
/// Extracts the [`Json`] from the incoming request.
|
||||||
///
|
///
|
||||||
/// _This extractor will take over the requested body, so you should avoid
|
/// _This extractor will take over the requested body, so you should avoid
|
||||||
/// using multiple extractors of this type in one handler._
|
/// using multiple extractors of this type in one handler._
|
||||||
///
|
///
|
||||||
/// - **Xml<T>**
|
/// - **Xml<T>**
|
||||||
///
|
///
|
||||||
/// Extracts the [`Xml`] from the incoming request.
|
/// Extracts the [`Xml`] from the incoming request.
|
||||||
///
|
///
|
||||||
/// _This extractor will take over the requested body, so you should avoid
|
/// _This extractor will take over the requested body, so you should avoid
|
||||||
/// using multiple extractors of this type in one handler._
|
/// using multiple extractors of this type in one handler._
|
||||||
///
|
///
|
||||||
/// - **TempFile**
|
/// - **TempFile**
|
||||||
///
|
///
|
||||||
/// Extracts the [`TempFile`] from the incoming request.
|
/// Extracts the [`TempFile`] from the incoming request.
|
||||||
///
|
///
|
||||||
/// _This extractor will take over the requested body, so you should avoid
|
/// _This extractor will take over the requested body, so you should avoid
|
||||||
/// using multiple extractors of this type in one handler._
|
/// using multiple extractors of this type in one handler._
|
||||||
///
|
///
|
||||||
/// - **Multipart**
|
/// - **Multipart**
|
||||||
///
|
///
|
||||||
/// Extracts the [`Multipart`] from the incoming request.
|
/// Extracts the [`Multipart`] from the incoming request.
|
||||||
///
|
///
|
||||||
/// _This extractor will take over the requested body, so you should avoid
|
/// _This extractor will take over the requested body, so you should avoid
|
||||||
/// using multiple extractors of this type in one handler._
|
/// using multiple extractors of this type in one handler._
|
||||||
///
|
///
|
||||||
/// - **&CookieJar**
|
/// - **&CookieJar**
|
||||||
///
|
///
|
||||||
@@ -209,7 +208,7 @@ impl RequestBody {
|
|||||||
/// - **&Session**
|
/// - **&Session**
|
||||||
///
|
///
|
||||||
/// Extracts the [`Session`](crate::session::Session) from the incoming
|
/// Extracts the [`Session`](crate::session::Session) from the incoming
|
||||||
/// request.
|
/// request.
|
||||||
///
|
///
|
||||||
/// _Requires `CookieSession` or `RedisSession` middleware._
|
/// _Requires `CookieSession` or `RedisSession` middleware._
|
||||||
///
|
///
|
||||||
@@ -218,54 +217,53 @@ impl RequestBody {
|
|||||||
/// Extracts the [`Body`] from the incoming request.
|
/// Extracts the [`Body`] from the incoming request.
|
||||||
///
|
///
|
||||||
/// _This extractor will take over the requested body, so you should avoid
|
/// _This extractor will take over the requested body, so you should avoid
|
||||||
/// using multiple extractors of this type in one handler._
|
/// using multiple extractors of this type in one handler._
|
||||||
///
|
///
|
||||||
/// - **String**
|
/// - **String**
|
||||||
///
|
///
|
||||||
/// Extracts the body from the incoming request and parse it into utf8
|
/// Extracts the body from the incoming request and parse it into utf8
|
||||||
/// [`String`].
|
/// [`String`].
|
||||||
///
|
///
|
||||||
/// _This extractor will take over the requested body, so you should avoid
|
/// _This extractor will take over the requested body, so you should avoid
|
||||||
/// using multiple extractors of this type in one handler._
|
/// using multiple extractors of this type in one handler._
|
||||||
///
|
///
|
||||||
/// - **Vec<u8>**
|
/// - **Vec<u8>**
|
||||||
///
|
///
|
||||||
/// Extracts the body from the incoming request and collect it into
|
/// Extracts the body from the incoming request and collect it into
|
||||||
/// [`Vec<u8>`].
|
/// [`Vec<u8>`].
|
||||||
///
|
///
|
||||||
/// _This extractor will take over the requested body, so you should avoid
|
/// _This extractor will take over the requested body, so you should avoid
|
||||||
/// using multiple extractors of this type in one handler._
|
/// using multiple extractors of this type in one handler._
|
||||||
///
|
///
|
||||||
/// - **Bytes**
|
/// - **Bytes**
|
||||||
///
|
///
|
||||||
/// Extracts the body from the incoming request and collect it into
|
/// Extracts the body from the incoming request and collect it into
|
||||||
/// [`Bytes`].
|
/// [`Bytes`].
|
||||||
///
|
///
|
||||||
/// _This extractor will take over the requested body, so you should avoid
|
/// _This extractor will take over the requested body, so you should avoid
|
||||||
/// using multiple extractors of this type in one handler._
|
/// using multiple extractors of this type in one handler._
|
||||||
///
|
///
|
||||||
/// - **WebSocket**
|
/// - **WebSocket**
|
||||||
///
|
///
|
||||||
/// Ready to accept a websocket [`WebSocket`](websocket::WebSocket)
|
/// Ready to accept a websocket [`WebSocket`](websocket::WebSocket)
|
||||||
/// connection.
|
/// connection.
|
||||||
///
|
///
|
||||||
/// - **Locale**
|
/// - **Locale**
|
||||||
///
|
///
|
||||||
/// Extracts the [`Locale`](crate::i18n::Locale) from the incoming
|
/// Extracts the [`Locale`](crate::i18n::Locale) from the incoming request.
|
||||||
/// request.
|
|
||||||
///
|
///
|
||||||
/// - **StaticFileRequest**
|
/// - **StaticFileRequest**
|
||||||
///
|
///
|
||||||
/// Ready to accept a static file request
|
/// Ready to accept a static file request
|
||||||
/// [`StaticFileRequest`](static_file::StaticFileRequest).
|
/// [`StaticFileRequest`](static_file::StaticFileRequest).
|
||||||
///
|
///
|
||||||
/// - **Accept**
|
/// - **Accept**
|
||||||
///
|
///
|
||||||
/// Extracts the `Accept` header from the incoming request.
|
/// Extracts the `Accept` header from the incoming request.
|
||||||
///
|
///
|
||||||
/// - **PathPattern**
|
/// - **PathPattern**
|
||||||
///
|
///
|
||||||
/// Extracts the matched path pattern from the incoming request.
|
/// Extracts the matched path pattern from the incoming request.
|
||||||
///
|
///
|
||||||
/// # Create your own extractor
|
/// # Create your own extractor
|
||||||
///
|
///
|
||||||
@@ -347,44 +345,46 @@ pub trait FromRequest<'a>: Sized {
|
|||||||
/// - **&'static str**
|
/// - **&'static str**
|
||||||
///
|
///
|
||||||
/// Sets the status to `OK` and the `Content-Type` to `text/plain`. The
|
/// Sets the status to `OK` and the `Content-Type` to `text/plain`. The
|
||||||
/// string is used as the body of the response.
|
/// string is used as the body of the response.
|
||||||
///
|
///
|
||||||
/// - **String**
|
/// - **String**
|
||||||
///
|
///
|
||||||
/// Sets the status to `OK` and the `Content-Type` to `text/plain`. The
|
/// Sets the status to `OK` and the `Content-Type` to `text/plain`. The
|
||||||
/// string is used as the body of the response.
|
/// string is used as the body of the response.
|
||||||
///
|
///
|
||||||
/// - **&'static [u8]**
|
/// - **&'static [u8]**
|
||||||
///
|
///
|
||||||
/// Sets the status to `OK` and the `Content-Type` to
|
/// Sets the status to `OK` and the `Content-Type` to
|
||||||
/// `application/octet-stream`. The slice is used as the body of the response.
|
/// `application/octet-stream`. The slice is used as the body of the
|
||||||
|
/// response.
|
||||||
///
|
///
|
||||||
/// - **Html<T>**
|
/// - **Html<T>**
|
||||||
///
|
///
|
||||||
/// Sets the status to `OK` and the `Content-Type` to `text/html`. `T` is
|
/// Sets the status to `OK` and the `Content-Type` to `text/html`. `T` is
|
||||||
/// used as the body of the response.
|
/// used as the body of the response.
|
||||||
///
|
///
|
||||||
/// - **Json<T>**
|
/// - **Json<T>**
|
||||||
///
|
///
|
||||||
/// Sets the status to `OK` and the `Content-Type` to `application/json`. Use
|
/// Sets the status to `OK` and the `Content-Type` to `application/json`. Use
|
||||||
/// [`serde_json`](https://crates.io/crates/serde_json) to serialize `T` into a json string.
|
/// [`serde_json`](https://crates.io/crates/serde_json) to serialize `T` into a json string.
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
/// - **Xml<T>**
|
/// - **Xml<T>**
|
||||||
///
|
///
|
||||||
/// Sets the status to `OK` and the `Content-Type` to `application/xml`. Use
|
/// Sets the status to `OK` and the `Content-Type` to `application/xml`. Use
|
||||||
/// [`quick-xml`](https://crates.io/crates/quick-xml) to serialize `T` into a xml string.
|
/// [`quick-xml`](https://crates.io/crates/quick-xml) to serialize `T` into a xml string.
|
||||||
///
|
///
|
||||||
/// - **Bytes**
|
/// - **Bytes**
|
||||||
///
|
///
|
||||||
/// Sets the status to `OK` and the `Content-Type` to
|
/// Sets the status to `OK` and the `Content-Type` to
|
||||||
/// `application/octet-stream`. The bytes is used as the body of the response.
|
/// `application/octet-stream`. The bytes is used as the body of the
|
||||||
|
/// response.
|
||||||
///
|
///
|
||||||
/// - **Vec<u8>**
|
/// - **Vec<u8>**
|
||||||
///
|
///
|
||||||
/// Sets the status to `OK` and the `Content-Type` to
|
/// Sets the status to `OK` and the `Content-Type` to
|
||||||
/// `application/octet-stream`. The vector’s data is used as the body of the
|
/// `application/octet-stream`. The vector’s data is used as the body of the
|
||||||
/// response.
|
/// response.
|
||||||
///
|
///
|
||||||
/// - **Body**
|
/// - **Body**
|
||||||
///
|
///
|
||||||
@@ -393,7 +393,7 @@ pub trait FromRequest<'a>: Sized {
|
|||||||
/// - **StatusCode**
|
/// - **StatusCode**
|
||||||
///
|
///
|
||||||
/// Sets the status to the specified status code [`StatusCode`] with an empty
|
/// Sets the status to the specified status code [`StatusCode`] with an empty
|
||||||
/// body.
|
/// body.
|
||||||
///
|
///
|
||||||
/// - **(StatusCode, T)**
|
/// - **(StatusCode, T)**
|
||||||
///
|
///
|
||||||
@@ -402,7 +402,7 @@ pub trait FromRequest<'a>: Sized {
|
|||||||
/// - **(StatusCode, HeaderMap, T)**
|
/// - **(StatusCode, HeaderMap, T)**
|
||||||
///
|
///
|
||||||
/// Convert `T` to response and set the specified status code [`StatusCode`],
|
/// Convert `T` to response and set the specified status code [`StatusCode`],
|
||||||
/// and then merge the specified [`HeaderMap`].
|
/// and then merge the specified [`HeaderMap`].
|
||||||
///
|
///
|
||||||
/// - **Response**
|
/// - **Response**
|
||||||
///
|
///
|
||||||
@@ -411,14 +411,14 @@ pub trait FromRequest<'a>: Sized {
|
|||||||
/// - **Compress<T>**
|
/// - **Compress<T>**
|
||||||
///
|
///
|
||||||
/// Call `T::into_response` to get the response, then compress the response
|
/// Call `T::into_response` to get the response, then compress the response
|
||||||
/// body with the specified algorithm, and set the correct `Content-Encoding`
|
/// body with the specified algorithm, and set the correct `Content-Encoding`
|
||||||
/// header.
|
/// header.
|
||||||
///
|
///
|
||||||
/// - **SSE**
|
/// - **SSE**
|
||||||
///
|
///
|
||||||
/// Sets the status to `OK` and the `Content-Type` to `text/event-stream`
|
/// Sets the status to `OK` and the `Content-Type` to `text/event-stream`
|
||||||
/// with an event stream body. Use the [`SSE::new`](sse::SSE::new) function to
|
/// with an event stream body. Use the [`SSE::new`](sse::SSE::new) function
|
||||||
/// create it.
|
/// to create it.
|
||||||
///
|
///
|
||||||
/// # Create you own response
|
/// # Create you own response
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user