ctx returns the request-scoped context for logging/cancellation.
()
| 208 | |
| 209 | // ctx returns the request-scoped context for logging/cancellation. |
| 210 | func (h *handler) ctx() context.Context { |
| 211 | if h.rqCtx == nil { |
| 212 | serverAddr, err := h.getServerAddr() |
| 213 | if err != nil { |
| 214 | base.AssertfCtx(h.rq.Context(), "Error getting server address: %v", err) |
| 215 | } |
| 216 | ctx := base.RequestLogCtx(h.rq.Context(), base.RequestData{ |
| 217 | CorrelationID: h.formatSerialNumber(), |
| 218 | RequestHost: serverAddr, |
| 219 | RequestRemoteAddr: h.rq.RemoteAddr, |
| 220 | }) |
| 221 | h.rqCtx = ctx |
| 222 | } |
| 223 | return h.rqCtx |
| 224 | } |
| 225 | |
| 226 | func (h *handler) getServerAddr() (string, error) { |
| 227 | return h.server.getServerAddr(h.serverType) |
no test coverage detected