Add a builder pattern to CorsOptions
morbatex opened this issue · comments
morbatex commented
If I'm not mistaken there are two ways right now if one wants to create CorsOptions which differ in some fields from the default option:
let cors_options = CorsOptions{ allow_credentials: true, max_age: Some(100), ..Default::default() };
or
let mut cors_options = CorsOptions::default();
cors_options.allow_credentials = true;
cors_options.max_age = Some(100);
Since the first variant (in my experience) is hardly used at all and the second one is very cumbersome, I would suggest a build pattern so that one could use the following code:
let cors_options = CorsOptions::default().allow_credentails(true).max_age(Some(100));
If you agree with this change, I would implement it and then open a Pull Request.
Yong Wen Chua commented
I personally use option 1, but I am open to making a new builder type too. If you are free to do so, please go ahead and open a PR. All contribution are welcomed!
Yong Wen Chua commented
Fixed by #75