flosse / rust-web-framework-comparison

A comparison of some web frameworks and libs written in Rust
5.01k stars 194 forks source link

Outdated and overcomplicated example for Rustful #2

Closed Ogeon closed 3 years ago

Ogeon commented 8 years ago

I noticed that the example for Rustful is a bit outdated and overcomplicated, compared to the other examples. The HandlerFn struct is no longer necessary, since Rust 1.3, and can be completely removed. It's also not really necessary to have a router if only one thing is served (unless you want to restrict requests to /). Handlers implements Router automatically. I'm not sure how minimal they should be, but here is a recent example of a very small server, including error handling.

Everything else looks correct, I think. The only exception would be the ? on "Static File Serving", which technically is correct but may be misleading. There is no middleware for it, but there are a couple of methods for it in Response. This breaks the pattern a bit...

I could send a PR, but there are a couple of uncertainties, as mentioned.

flosse commented 8 years ago

Thanks for your feedback!

I noticed that the example for Rustful is a bit outdated and overcomplicated, compared to the other examples. The HandlerFn struct is no longer necessary, since Rust 1.3, and can be completely removed.

good to know :)

It's also not really necessary to have a router if only one thing is served (unless you want to restrict requests to /). Handlers implements Router automatically. I'm not sure how minimal they should be, but here is a recent example of a very small server, including error handling.

Actually I'm not sure yet if I want to use explicit handler functions for the examples or not. At the moment it's mixed. Using minimal examples is great to get a quick impress but almost every project has this little example anyway.

Everything else looks correct, I think. The only exception would be the ? on "Static File Serving", which technically is correct but may be misleading. There is no middleware for it, but there are a couple of methods for it in Response. This breaks the pattern a bit...

So what would you suggest?

Ogeon commented 8 years ago

Thanks for your feedback!

It's nice of you to put together this comparison. I just want to help :)

Actually I'm not sure yet if I want to use explicit handler functions for the examples or not. At the moment it's mixed. Using minimal examples is great to get a quick impress but almost every project has this little example anyway.

The way that I see it is that minimalistic examples are often useful for getting a hang of the basic setup, but a more fleshed out one tells more about how it is to actually use it. Some things may look great at small scale, but become hideous when it grows, while other things may look overly complicated until it's used to its full potential. It's hard to find something that feels like "the real world", while keeping it easy to take in.

So what would you suggest?

I'm honestly not sure. I don't actually know if people will assume that the lack of a middleware will imply a lack of functionality or not, so maybe it doesn't matter. One "quick fix" could be to just write "built in" or something, but that may look strange. An other idea is to not assume that the functionality has to be a middleware. It depends on if the middleware or the functionality itself should be in focus.

flosse commented 3 years ago

this issue is obsolete because we don't have code examples anymore.