audit

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 1 Imported by: 0

README

Audit Middleware

What it does

Records structured audit events for requests, responses, identity, tenant, route, and error outcomes. It is intended for compliance, security review, and incident investigation.

How to implement

package main

import (
	"github.com/oarkflow/fh"
	"github.com/oarkflow/fh/mw/audit"
)

func main() {
	app := fh.New()
	app.Use(audit.New(audit.Config{}))

	app.Get("/", func(c fh.Ctx) error {
		return c.Status(fh.StatusOK).SendString("ok")
	})
}

Impact

Adds logging/sink overhead. The impact depends on the sink; asynchronous/batched sinks are preferred for high-throughput production services.

Ordering guidance

Run after authentication/tenant extraction and before handlers. Run after request ID/correlation ID so audit events are traceable.

Production considerations

Redact secrets and regulated data. Use append-only durable sinks for compliance. Define retention and access controls. Avoid logging request bodies by default.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg Config) fh.HandlerFunc

Types

type Config

type Config struct {
	Action     string
	Resource   string
	ResourceID func(fh.Ctx) string
	OnError    bool
	Next       func(fh.Ctx) bool
}

Jump to

Keyboard shortcuts

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