How it works...
Designing good APIs is hard and requires a good grasp of what's possible—especially with new frameworks and languages. actix-web has proven itself to be a versatile tool that proficiently uses types to achieve great results. Step 1 sets this up by importing a few types and traits.
Only in step 2 and step 3 does it get more interesting. Here, we define the various handlers in almost all of the ways actix-web allows us to, by either using the attribute that wraps a function into a factory (underneath it's all asynchronous actors; check out Handle asynchronous messages with actors in Chapter 4, Fearless Concurrency ) or letting the web::resource() type do that. Either way, every handler function has a route associated with it ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access