InitRequestWithCancel returns a commit function with a boolean arg. If the arg is false, future calls to commit() will not create an audit log entry.
(w http.ResponseWriter, p *RequestParams)
| 405 | // If the arg is false, future calls to commit() will not create an audit log |
| 406 | // entry. |
| 407 | func InitRequestWithCancel[T Auditable](w http.ResponseWriter, p *RequestParams) (*Request[T], func(commit bool)) { |
| 408 | req, commitF := InitRequest[T](w, p) |
| 409 | canceled := false |
| 410 | return req, func(commit bool) { |
| 411 | // Once 'commit=false' is called, block |
| 412 | // any future commit attempts. |
| 413 | if !commit { |
| 414 | canceled = true |
| 415 | return |
| 416 | } |
| 417 | // If it was ever canceled, block any commits |
| 418 | if !canceled { |
| 419 | commitF() |
| 420 | } |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | // InitRequest initializes an audit log for a request. It returns a function |
| 425 | // that should be deferred, causing the audit log to be committed when the |
no outgoing calls
no test coverage detected