Documentation
¶
Overview ¶
Package oprec turns HTTP management mutations into audit operation records. It lives in the audit module and is consumed by other modules' HTTP adapters, so audit semantics (including recording failed operations) have a single source of truth.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Audit ¶
type Audit interface {
RecordOperation(context.Context, auditusecase.OperationInput) (auditusecase.OperationLog, error)
}
Audit persists operation records; it is satisfied by the audit usecase.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder records management operations for audit.
func (*Recorder) Record ¶
func (r *Recorder) Record(c *echo.Context, action, resource, resourceID, message string, opErr error) error
Record fills the actor and request fields from the Echo context and records one management operation. A non-nil opErr marks the operation failed, and failed operations are recorded too. Record returns opErr when the operation failed (an audit failure is logged instead of masking it) and the audit error otherwise, so handlers call it on both paths:
result, opErr := h.usecase.DoSomething(ctx, input)
if err := h.audit.Record(c, "do", "thing", id, "did something", opErr); err != nil {
return err
}
if opErr != nil {
return opErr
}