This chapter covers
- Adding in-memory storage to our application
- Passing around state to the route handlers
- Reading from the in-memory storage across threads
- Updating the in-memory storage in a thread-safe manner
- Parsing data out of JSON and url-form bodies
- Extracting information out of query parameters
- Adding custom errors to our application
In the previous chapter, we started building our Q&A web service. We created our first custom types, Question and QuestionId, and started to handle error cases and return them to the user. So far, we’ve implemented the GET route for /questions and return 404 when any other path or method is requested. This chapter will expand massively on this functionality. We continue to use our GitHub repository for this book (http://mng.bz/BZzJ).
We’ll add all missing HTTP methods (POST, PUT, and DELETE) and add the Answer type as well. Figure 4.1 gives an overview of which endpoints we plan to implement in this chapter.
Figure 4.1 We implemented the GET route for questions in chapter 3; this chapter covers POST, PUT, and DELETE, as well as adding comments via POST.
