It's really a shame they haven't jumped on tokio yet. Then again, I tried to look at the code, and it didn't seem to be a simple dropin thing to move over to tokio.
It's far from clear if tokio is not a dead end.
Rocket, Rust Web Framework, v0.3: Fairings, TLS, Private Cookies
61–70 of 75 posts
Re: Rocket, Rust Web Framework, v0.3: Fairings, TLS, Private Cookies
#62Re: Rocket, Rust Web Framework, v0.3: Fairings, TLS, Private Cookies
#63Earlier quoted context omitted.
Isn't Postgres worth coupling to? SQLite is a close favorite, for different reasons.
Web servers and database management are two vastly different domains. I'm wary of frameworks that attempt to impose an opinion on both.
Re: Rocket, Rust Web Framework, v0.3: Fairings, TLS, Private Cookies
#64I'm a Rocket fan and glad to see this big slate of improvements. On the other hand, I do want to register a bit of concern regarding the plan to add "first-class database support" for 0.4. I hope that doesn't result in a close coupling to any particular database, or to using a database in general.
Re: Rocket, Rust Web Framework, v0.3: Fairings, TLS, Private Cookies
#65Hey Sergio, Regarding fairings, it seems a missing "middleware" case might be the sorts of things that cause redirects on entry (e.g. redirect routes with/without trailing slashes to the latter as a super trivial example). Is that something you'd expect to support in some way? I think that's something that doesn't feel like it maps either to guards or fairings well at the moment. I did see where you mentioned your di…
on_request => |request, _| {
if request.uri().path().ends_with('/') {
let new_path = request.uri().path()[..-1];
request.set_uri(URI::new(new_path));
}
}
You can also use a fairing If you want to return a 302 (or similar) so that the browser does the redirect instead. In this case, you'd implement a response fairing that rewrites failed responses to return a redirect to the appropriate URI. Again, in pseudocode, this would look like: on_response => |request, response| {
if response.status() == Status::NotFound && request.uri().path().ends_with('/') {
response.set_status(Status::Found);
response.set_header(Location(request.uri().path()[..-1]));
response.take_body();
}
}
Take a look at the fairings guide [0] and fairings documentation [1] for more ideas![0]: https://rocket.rs/guide/fairings/
[1]: https://api.rocket.rs/rocket/fairing/trait.Fairing.html
Re: Rocket, Rust Web Framework, v0.3: Fairings, TLS, Private Cookies
#66Earlier quoted context omitted.
For that list of features and the discussion around them, https://github.com/SergioBenitez/Rocket/issues/19
i128 really surprises me. Why would a web framework need 128 bit integers?
https://github.com/SergioBenitez/Rocket/blob/master/codegen/...
Re: Rocket, Rust Web Framework, v0.3: Fairings, TLS, Private Cookies
#67I don't have any experience in Rust. From what I read, Rust is a low level / system programming language. Comparing to dynamic languages like Python, I understand that Rust is much faster. However, Python is fast enough for most web applications. So why should I use Rust in web development? Even if the library ecosystem were mature enough, could I expect my productivity could become nearly high as in Python?
I'd say it's true that Python is fast enough for most web servers. Rather than strictly considering performance, I'd guess that people seeking to do webdev in Rust are looking to leverage Rust's static analysis to improve resilience, trading off up-front productivity for long-term maintainability (which isn't to denigrate Python, which I love, but fearless refactoring really is something that compiled langs excel at)…
Would you say that's a feature of compilation? I'd have said it's Rust's strong and static type system that makes refactoring 'fearless' and generally aids productivity and maintainability.
Python ≥3.6 with liberal type hinting is a more interesting comparison in my view.
Re: Rocket, Rust Web Framework, v0.3: Fairings, TLS, Private Cookies
#68Earlier quoted context omitted.
Isn't Postgres worth coupling to? SQLite is a close favorite, for different reasons.
As someone who only uses Postgres and SQLite: No. It's not. People inevitably have to deal with preexisting systems they can't modify for their needs.
Re: Rocket, Rust Web Framework, v0.3: Fairings, TLS, Private Cookies
#69Earlier quoted context omitted.
How so?
Overly complicated
Re: Rocket, Rust Web Framework, v0.3: Fairings, TLS, Private Cookies
#70How is the performance of Rocket? So far all the Rust web frameworks I've seen have pretty disappointing performances. I was expecting C++/Java/Go level of performance. Instead, Tokio & Iron turn out to be slower than many frameworks in Ruby, Python, PHP, JS: https://www.techempower.com/benchmarks/#section=data-r14&hw=... https://www.techempower.com/benchmarks/#section=data-r14&hw=... https://www.techempower.com/benc…
* iron isn't using async io which is very important for Techempower * Tokio-minihttp is #4 overall on the plaintext benchmark there, which is sort of the "what is the max performance" benchmark I don't know of anyone who is really actively looking at Techempower and optimizing based on it, which is how you win benchmarks.
(Literally, I don't care about the performance, I just want that style of API.)