From the course: Rust Web Frameworks: Build Real World Projects with Actix, Rocket, Warp, Tide, and std Library
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Challenge: Building a basic API that returns a message - Rust Tutorial
From the course: Rust Web Frameworks: Build Real World Projects with Actix, Rocket, Warp, Tide, and std Library
Challenge: Building a basic API that returns a message
(upbeat music) - [Instructor] Welcome. In this video we are going to take on a challenge where we have to build something using the standard library. So here's the challenge. We have to construct an API that responds to the endpoint slash a API with a JSON message. On the other hand, if the endpoint doesn't match, we want to return a 404 not found error. We'll be relying solely on the standard library for this. So let's harness the power of Rust without external dependencies. And the approach for this challenge would be we'll need to set up a basic HDP server, which we have seen in the past videos. Here are the steps to help you guide through this challenge. Step one is establish a TCP listener to handle incoming connections. Step two is that for each connection spawn new thread to handle it concurrently. Step three is inside the handle function. Read the client's request and determine the requested endpoint. Step four is that if the endpoint is slash API respond with a JSON message…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Introduction to the standard Rust library3m 32s
-
(Locked)
Important functions, features, and concepts3m 36s
-
(Locked)
Building a server with the std library3m 47s
-
(Locked)
Extra, helpful features in the std library3m 35s
-
(Locked)
Tokio and asynchronous programming3m 27s
-
(Locked)
Challenge: Building a basic API that returns a message1m 21s
-
(Locked)
Solution: Building a basic API that returns a message3m 49s
-
-
-
-
-
-