In this feature, an apprentice will build an HTTP server which includes routes, requests, and responses. The routes must be customizable with a URL, a verb, and an action to take when the route is called. This work will form the basis of many other features.
This feature corresponds to the acceptance tests in 01_getting_started
in the HTTP Server Spec.
A user should be able to interact with the HTTP server as follows:
- When a client sends a properly formatted request to the server, the server sends an appropriate response back to the client.
- A client can send different HTTP requests to the server and get the appropriate response back each time.
- Different clients can send messages to server and get back their proper responses.
- The server should be able to handle 200, 300, and 400-level responses. Not every response code needs to be complete, but there should be a few representative response codes implemented for each level.
- The server should establish a socket connection with the client using a low-level socket library. The goal of this exercise is to work with sockets directly.
- The server should accept and return streams of data rather than raw strings.
- The HTTP server should be covered by a robust suite of unit tests.
- The HTTP server should pass all of the tests covered in
01_getting_started
in the HTTP Server Spec.
- Elixir 1.15.2
- Erlang/OTP 26
- Echo Server
- Clone the repository to your local computer.
- Use your terminal to navigate into your new http_server folder and install project dependencies by running
mix compile
. - To start the HTTP Server, call
mix start
from within the http_server folder.
For more information about connecting to the server as a client, basic routing, as well as handling redirects and static files, please see the doc folder.
To run the ExUnit test suite, call mix test
from within the http_server folder.
- Ruby 2.7.6
- Start your HTTP server by calling
MIX_ENV=integration_test mix start
from within the http_server folder. - Use your terminal to navigate into the
test/http_server_spec
folder and install project dependencies by runningbundle install
. - Once the server is running, call
rake test
from within the http_server_spec folder. - You can also run the tests from a specific section of the features:
rake test:f1 # Run all of the tests in 01_getting_started
rake test:f2 # Run all of the tests in 02_structured_data
rake test:f3 # Run all of the tests in 03_file_server
rake test:f4 # Run all of the tests in 04_todo_list
See test/http_server_spec/README.md
for more information about the acceptance tests.