Fix compiling without features
This commit is contained in:
parent
fbcae8aa29
commit
91f059f9ee
|
@ -16,16 +16,24 @@ use futures::io::AsyncRead;
|
|||
use futures::AsyncReadExt;
|
||||
|
||||
/// Receive a GraphQL request from a content type and body.
|
||||
///
|
||||
/// If the content type is multipart it will use `receive_multipart`, otherwise it will use
|
||||
/// `receive_json`.
|
||||
#[cfg(feature = "multipart")]
|
||||
pub async fn receive_body(
|
||||
content_type: Option<impl AsRef<str>>,
|
||||
body: impl AsyncRead + Send + 'static,
|
||||
opts: MultipartOptions,
|
||||
) -> Result<Request, ParseRequestError> {
|
||||
#[cfg(feature = "multipart")]
|
||||
if let Some(Ok(boundary)) = content_type.map(multer::parse_boundary) {
|
||||
return receive_multipart(body, boundary, opts).await;
|
||||
receive_multipart(body, boundary, opts).await
|
||||
} else {
|
||||
receive_json(body).await
|
||||
}
|
||||
}
|
||||
|
||||
/// Receive a GraphQL request from a body as JSON.
|
||||
pub async fn receive_json(body: impl AsyncRead + Send + 'static) -> Result<Request, ParseRequestError> {
|
||||
let mut data = Vec::new();
|
||||
futures::pin_mut!(body);
|
||||
body.read_to_end(&mut data)
|
||||
|
|
|
@ -11,9 +11,12 @@ use std::task::{Context, Poll};
|
|||
|
||||
/// Options for `receive_multipart`.
|
||||
#[derive(Default, Clone)]
|
||||
#[non_exhaustive]
|
||||
pub struct MultipartOptions {
|
||||
max_file_size: Option<usize>,
|
||||
max_num_files: Option<usize>,
|
||||
/// The maximum file size.
|
||||
pub max_file_size: Option<usize>,
|
||||
/// The maximum number of files.
|
||||
pub max_num_files: Option<usize>,
|
||||
}
|
||||
|
||||
impl MultipartOptions {
|
||||
|
|
Loading…
Reference in New Issue
Block a user