A Formal Introduction to Handlers 1 - 5
What
In the past few stories you have learned about what handlers are and what their code looks like. In this story you are going to be formally introduced to the first five handlers in Gorouter.
How
- Read the summary for each handler.
- Where there is a ✨ make sure you take a look at the code.
The first five handlers
1. ✨Panic Check If a request/response causes a panic this handler will catch it and log. This way the gorouter continues working for other requests.
2.✨ Request Info This handler creates the RequestInfo struct. There is one per request. The handlers use this struct to pass information to other handlers. For example, this handler sets the reqInfo.StartedAt time to time.Now(). Later the access log handler will use this information.
3. Proxy Writer This handler creates the response writer.
4. Vcap Request ID Header This handler generates and sets the “X-Vcap-Request-Id” on the request. This header value is unique per each request and is used for debugging and tracing requests/responses through different components.
5. HTTP Start Stop
This handler emits HTTP Start Stop events. You can see these events by installing the firehose nozzle, sending traffic to an app, and watching for this event: cf nozzle --filter HttpStartStop | grep gorouter
Questions
❓Why do you think that the panic handler is first?