actor

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 2 Imported by: 0

README

Actor Middleware

What it does

Derives an actor key for the request and stores it in request context. It is useful for audit trails, policy decisions, rate limiting, and tenant/user-aware logging.

How to implement

package main

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

func main() {
	app := fh.New()
	app.Use(actor.New(actor.Config{Key: func(c fh.Ctx) string { return c.Get("X-Actor-ID") }}))

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

Impact

Adds a small amount of per-request work to resolve the actor. The value can improve observability and authorization traceability across the stack.

Ordering guidance

Run after authentication or header normalization middleware if the actor is derived from a principal or trusted header. Run before audit/policy/logging middleware that consumes the actor.

Production considerations

Do not trust public actor headers unless they are set by a trusted gateway. Prefer deriving the actor from fh.Principal, JWT claims, mTLS identity, or a verified API key.

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{ Key func(fh.Ctx) string }

Jump to

Keyboard shortcuts

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