-
Notifications
You must be signed in to change notification settings - Fork 329
Options Method #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Options Method #104
Conversation
So I dug around a bit and I think it has to do with the fact that the endpoint function is being constructed in tide vs tide being linked as a dependency to a different binary. I tried simplifying the logic and removed the recursive call and reduced the code to the following: let resource = resource.as_mut().unwrap();
if resource.endpoints.contains_key(&method) {
panic!("A {} endpoint already exists for this path", method)
}
if !resource.endpoints.contains_key(&http::Method::OPTIONS) {
resource.method_options.push(method.as_str().to_string());
let option_header = resource.method_options.join(", ");
let callback = async || {
http::Response::builder()
.status(http::status::StatusCode::OK)
.header("Content-Type", "text/plain")
.body(Body::empty())
.unwrap()
};
resource
.endpoints
.insert(http::Method::OPTIONS, BoxedEndpoint::new(callback));
}
resource.endpoints.insert(method, BoxedEndpoint::new(ep));
} And now I'm getting a similar error, but with more information: error[E0277]: the trait bound `Data: std::clone::Clone` is not satisfied
--> src/router.rs:222:48
|
222 | .insert(http::Method::OPTIONS, BoxedEndpoint::new(callback));
| ^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `Data`
|
= help: consider adding a `where Data: std::clone::Clone` bound
= note: required because of the requirements on the impl of `endpoint::Endpoint<Data, (endpoint::Ty<impl core::future::future::Future>,)>` for `[closure@src/router.rs:213:28: 219:14]` The same error is repeated for Maybe @aturon might have some more insight into this. |
ping @tzilist do you have any status updates on this PR? Do reckon you have the bandwidth to make the final changes? |
@yoshuawuyts Apologies, work picked up over the holidays and I probably wont have a ton of time to work on this for a while :( if someone else wants to pick it up that'd be great! I hope to come back and contribute some more in the next month or so! |
@tzilist no worries; I appreciate the quick reply! I might pick up the suggested changes, and try to get this landed. Would be really cool to have this patch in Tide I think! ✨ |
6318f00
to
da87f0f
Compare
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
PR is ready for review! CI is currently blocked on Created #115 to add back the access-control headers that were not included in this patch's scope. Thanks! |
@tzilist are you interested in rebasing this PR? |
@aturon sorry just saw this! I wish I had time, kinda in the middle of a crunch at work! If it's still up in a few weeks I'd be happy to! |
Description
Tide will now automatically implement the
OPTIONS
method by checking which methods are available for a specific path. Currently, the implementation fails to compile with this error message and I am stuck trying to figure out what the issue is :/Any help would be greatly appreciated!
Motivation and Context
closes #51
How Has This Been Tested?
Not yet, implementation currently does not compile
Types of changes
Checklist: