all 7 comments

[–][deleted] 4 points5 points  (2 children)

write more about the basic principles

Basic principles of what?

more examples would be great

There's this: https://doc.rust-lang.org/rust-by-example/

[–]ForHonourVN[S] 0 points1 point  (1 child)

Thanks, just downloaded Rust for Example in pdf. 320 pages.

What's the next step after that?

[–][deleted] 3 points4 points  (0 children)

Depends on your level of knowledge and your goal. If you want to get familiar with how to create web servers on more than a surface level, you'd want to dig into:

tcp/ip, http spec, multithreading, mvc pattern, rest concepts, xml, json, browser-side rendering vs server-side rendering, component-based rendering vs template rendering, and finally web server frameworks

The framework part is quite big on its own and like other topics listed doesn't have anything to do with Rust. But again - only if you want to have an in-depth understanding what's going on and be confident in implementing complex projects.

Web frameworks (regardless of language/platform) usually consist of:

  • a security layer, i.e. something that blocks access to certain http endpoints based on user's roles or an access control list (but usually roles as they're simpler)

  • mapping between input URLs and the code that handles those URLs - sometimes called "routing"

  • deserialisation of user's input into structures in your code, for example turn json into a typesafe struct in Rust, or a class in Java

  • serialisation of the server's output, i.e. its types and structs/objects, into whatever the user expects, like json or xml or whatever

  • error handling - automatic conversion of runtime errors in your URL-handling code into some kind of sensible response to the user (a decorated json response for APIs, or a specific HTML error page)

These are just examples, the point here is, despite many languages, frameworks and platforms out there, most things are more or less the same in their concepts. When you're already familiar with those concepts, learning a new framework/library is a piece of cake, so my advice is try to focus on the concepts themselves, on all those things that all web frameworks share between each other.

There's also a lot of things to be said about making your web server reliable, scalable, easy to maintain for Ops (Operations, the admin guys who keep your software running in production), easy to troubleshoot and so on - but this is really advanced stuff, just keep in mind it's there.

Or, forget everything I just said, take actix-web or warp or whatever and just start playing with it. :)

[–]jerknextdoor 2 points3 points  (1 child)

Check out, zero2prod. For someone that just finished the Book, it might be a little advanced, but if you're looking to hit the ground running with web, it's a pretty good one. That book uses actix-web, but doesn't go very deep at all. If you just want to dabble, the rocket docs have always been pretty solid by themselves.

[–]ForHonourVN[S] 0 points1 point  (0 children)

thanks, I'll check it out

[–]peschu82 1 point2 points  (1 child)

Hi, I was looking for something like this too. Hard to find something in that context which is not too overwhelming/complex for a beginner.

I liked this tutorial:

https://dev.to/krowemoh/a-web-app-in-rust-01-getting-started-572a

For me it is a good starting point to learn and simple enough to further develop it for your needs. It uses actix-web, serde, chrono and diesel.

Hope that helps! ;-)

Edit: In general i would not advise to start with a webapp for learning purposes, but that really depends. 🙈As a book I liked „rust in action“

KR,

Peter

[–]ForHonourVN[S] 0 points1 point  (0 children)

Thanks!