-
Notifications
You must be signed in to change notification settings - Fork 321
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
introduce better app configurability #159
Conversation
@prasannavl I think this direction is pretty good! An alternative structure is to create a builder where each feature can be enabled manually (tho saying that out loud makes me realize that's not necessary in contradiction to the API you're proposing). This seems like a reasonable enough addition. However we should probably block merging this until #156 is done to see how it fits into the larger picture. |
Oh, just looked into the diff of #156. You're right, doesn't make much sense to merge at this point. PS. I did think about the builder, but just felt it was overkill at this stage. Especially considering Configuration already had builder and didn't like the idea of having builder after builder as opposed to the nice API it currently offered. That said, looks like #156 should make all this better and bring more clarity. |
Can I suggest |
@mehcode - That was my first line of thought too. Unfortunately though, since |
Just giving a little bit of thought to #156, since there App::new just returns an empty one. I see multiple ways to do this.
let mut app = App:with_default(Data); // Note this is not the `Default` trait.
app.serve(addr)
let mut app = App::new(Data);
tide::middleware::use_defaults(&mut app);
app.serve(addr);
let mut app = App::new(Data);
app.use_defaults();
app.serve(addr); (or) even let mut app = App::new(Data).defaults();
app.serve(addr); |
Yep, with #156 we'll need to think through this question again. It's also tied to how we want to divide up the "core" framework versus middleware and other extensions -- I'll open up a distinct issue on that for further discussion. |
Issue up: #162 |
@prasannavl can this be closed now that #162 is up? |
Yup! Was thinking of doing a cleanup run myself just now. Closing. |
Currently,
App::new()
automatically sets up logging middleware. When this is not desirable there is not way to remove it.While configurability of tide in general is an ongoing process, and will change as we go, I expect some form default middleware and other options to be pre-configured, logging being a prime example. However there should also be a way out for people who'd prefer starting from scratch.
So, as the configuration story improves, I think a nice to way to handle this throughout (either for just the current evolutionary phases of tide, or through to more mature phases if it desired), would be to introduce to a method
App::empty()
which is basicallynew
with bare bones. Andnew
as usual, provides sensible defaults.