| 184 | } |
| 185 | |
| 186 | func newHandler(server *ServerContext, privs handlerPrivs, serverType serverType, r http.ResponseWriter, rq *http.Request, options handlerOptions) *handler { |
| 187 | h := &handler{ |
| 188 | server: server, |
| 189 | privs: privs, |
| 190 | rq: rq, |
| 191 | response: NewNonCountedResponseWriter(r), |
| 192 | status: http.StatusOK, |
| 193 | serialNumber: atomic.AddUint64(&lastSerialNum, 1), |
| 194 | startTime: time.Now(), |
| 195 | runOffline: options.runOffline, |
| 196 | allowNilDBContext: options.allowNilDBContext, |
| 197 | authScopeFunc: options.authScopeFunc, |
| 198 | httpLogLevel: options.httpLogLevel, |
| 199 | serverType: serverType, |
| 200 | sgcollect: options.sgcollect, |
| 201 | } |
| 202 | |
| 203 | // initialize h.rqCtx |
| 204 | _ = h.ctx() |
| 205 | |
| 206 | return h |
| 207 | } |
| 208 | |
| 209 | // ctx returns the request-scoped context for logging/cancellation. |
| 210 | func (h *handler) ctx() context.Context { |