Module 10 Activity
Scenario
Put an interface in front of it, without the interface becoming the weakest part.
What you build
An endpoint with validation on the request model, honest streaming, a timeout the user can understand, and slow work off the request path.
Steps
- Build one endpoint with a request model and a response shape. Exercise it with
TestClient, no server. - Move all validation onto the request model so it runs before your handler.
- Stream a response and state what you would do if validation failed after streaming began.
- Set a timeout shorter than the infrastructure in front of you, with a message containing a request id.
- Move anything slower than a couple of seconds off the request path: accept, return an id, let the client return.
- Confirm the whole thing is exercised without starting a server.
Evidence to hand in
- The endpoint and its
TestClienttests. - Validation on the request model.
- The streaming endpoint and your post-validation policy.
- The timeout and its message.
- The accept-and-poll flow.
Review checklist
- Validation runs before the handler body.
- The streaming policy addresses failed validation after streaming.
- The timeout is shorter than the infrastructure's and carries a request id.
- Slow work does not hold the connection open.
- Tests run with no server and no network.
