This chapter will be the most “reference-y” of the book, with each topic covered using the briefest examples possible to avoid cluttering the discussion with unrelated facets. The next few chapters will delve into the more theoretical and architectural aspects of Sinatra, then we’ll turn our attention to practical application and create several projects that are more involved and cover a wider breadth of knowledge.
The core of any Sinatra application is the ability to respond to one or more routes. Routes are the primary way that users interact with your application. To understand how Sinatra handles routing, we must first examine HTTP, the Hypertext Transfer Protocol.
The discussion takes place from the perspective of the server; a request is created by a client (which may be a browser, another web application, etc.), and a response is created by the server and sent back.
This is also true with regard to operating on
response objects in Sinatra, which we will discuss throughout this chapter; the former ...