-
Notifications
You must be signed in to change notification settings - Fork 173
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
ensure_usable_cors_rules() isn't client friendly #272
Comments
I don't really understand what you mean with
|
Returning Something like |
I'll try to clarify why this is potentially useful: @jplatte What I mean by I could have a go at trying to implement something for a draft PR if this is something that you think would be useful in |
Alright, I guess if let Err(e) = self.validate() {
panic!("{}", e);
} |
I think I'm gonna experiment with some sort of builder that doesn't panic. |
Feature Request
Motivation
We are using tower-http in our project and we allow users to configure CORS. If there is a mistake which we can't detect in the composition of those rules, then this can result in a runtime panic in the
ensure_usable_cors_rules()
fn. This is not a good experience and we are working around this at the moment by validating our CORS rules before we pass them into tower-http.Proposal
Could we modify
ensure_usable_cors_rules()
so that rather thanassert
ing rules are usable, returns a result and expose this function so that we can validate before attempting to create a CorsLayer?:Alternatives
Perhaps have a
try_layer()
on Cors (or CorsLayer?) which is a fallibleCorsLayer
creator? If we had this, we could keep the original assert basedensure_usable_cors_rules()
and add a new private fallible ensurer for consumption intry_layer
. I feel like this would be the cleanest solution.The text was updated successfully, but these errors were encountered: