-
Notifications
You must be signed in to change notification settings - Fork 86
Closed
Description
I need a fourth extractor in my endpoint, which currently does not seem to be possible.
My endpoint is defined like this
#[endpoint {
method = POST,
path = "/upload/{id}/chunk",
}]
pub async fn upload_chunk(
rqctx: RequestContext<AppContext>,
auth_headers: Header<AuthHeaders>,
query: Query<UploadChunkQuery>,
path: DsPath<UploadPath>,
body: UntypedBody,
) -> Result<HttpResponseUpdatedNoContent, HttpError>
which gives the following error
118 | pub async fn upload_chunk(
| ^^^^^^^^^^^^ the trait `dropshot::handler::HttpHandlerFunc<_, _, _>` is not implemented for fn item `fn(RequestContext<AppContext>, Header<AuthHeaders>, Query<...>, ..., ...) -> ... {upload_chunk}`
This seems to be due to the fact that only up to 3 extractors are supported, as documented here:
Lines 344 to 347 in 83f78e7
//! `StreamingBody`, and `RawRequest` impl `ExclusiveExtractor`. Your function | |
//! may accept 0-3 extractors, but only one can be `ExclusiveExtractor`, and it | |
//! must be the last one. Otherwise, the order of extractor arguments does not | |
//! matter. |
I am wondering what the reason for this is and whether you would be willing to accept a PR that increases this limit to 4. Or is there another way to have more extractors that I overlooked?
The following changes on a local version of dropshot make my above code compile, but this may have some side-effects that I don't fully understand:
--- a/dropshot/src/extractor/common.rs
+++ b/dropshot/src/extractor/common.rs
@@ -207,3 +207,4 @@ macro_rules! impl_rqextractor_for_tuple {
// extractors and exactly one exclusive extractor.
impl_rqextractor_for_tuple!(S1);
impl_rqextractor_for_tuple!(S1, S2);
+impl_rqextractor_for_tuple!(S1, S2, S3);
diff --git a/dropshot/src/handler.rs b/dropshot/src/handler.rs
index de589a4..9625e43 100644
--- a/dropshot/src/handler.rs
+++ b/dropshot/src/handler.rs
@@ -680,6 +680,7 @@ impl_HttpHandlerFunc_for_func_with_params!();
impl_HttpHandlerFunc_for_func_with_params!((0, T0));
impl_HttpHandlerFunc_for_func_with_params!((0, T1), (1, T2));
impl_HttpHandlerFunc_for_func_with_params!((0, T1), (1, T2), (2, T3));
+impl_HttpHandlerFunc_for_func_with_params!((0, T1), (1, T2), (2, T3), (3, T4));
Metadata
Metadata
Assignees
Labels
No labels