HTTP Methods
You are currently handling a POST request to /uppercase. But what if a client sends a
GET request to that same path?
Endpoints often only support specific HTTP Methods (GET, POST, PUT, DELETE, etc.).
According to RFC 9110 Section 9.3:
The method token indicates the request method to be performed on the target resource. The request method is the primary source of semantics for a request message.
If a client attempts to use a method that the server does not support for a specific resource,
the server should respond with a 405 Method Not Allowed status code.
Your Task
Protect your /uppercase route!
- If it receives a
POSTrequest, function normally (read the body, uppercase it, return it). - If it receives any other method (like
GET), respond immediately with405 Method Not Allowed(and no response body).
Important
Run the below docker command to test your solution.
docker run \ --rm \ --add-host host.docker.internal:host-gateway \ codeberg.org/level0/buildit/http-server:latest \ --addr host.docker.internal:8080 \ --until http_methods