oprec

package
v0.0.0-...-a7ad5ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

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 New

func New(audit Audit) *Recorder

New creates an operation recorder backed by 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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL