Documentation
¶
Overview ¶
Package transport is the common HTTP boundary. Business handlers remain in their module and perform resource-specific checks through their services.
Index ¶
- Variables
- func EnsureRequestID(w http.ResponseWriter, r *http.Request) (*http.Request, string, error)
- func JSON(w http.ResponseWriter, status int, value any)
- func NewHandler(registry *module.Registry, routes []Route, authn Authenticator, ...) (handler http.Handler, err error)
- func RequestID(ctx context.Context) string
- func WithUnavailableCode(handler http.Handler, code string) http.Handler
- type Access
- type Authenticator
- type Authorizer
- type Error
- type Principal
- type Resource
- type Route
- type SourceLimiter
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnauthenticated = errors.New("authentication required") ErrForbidden = errors.New("permission denied") )
Functions ¶
func EnsureRequestID ¶ added in v0.2.1
EnsureRequestID reuses the active context request ID or generates a new one, ensuring X-Request-ID and X-Content-Type-Options headers are present.
func NewHandler ¶
func NewHandler(registry *module.Registry, routes []Route, authn Authenticator, authz Authorizer, logger *slog.Logger) (handler http.Handler, err error)
NewHandler rejects ambiguous registrations and requires explicit public or protected access. An absent identity adapter never implies anonymous access.
Types ¶
type Authenticator ¶
type Authorizer ¶
type SourceLimiter ¶ added in v0.2.0
type SourceLimiter struct {
Now func() time.Time
Limit int
Window time.Duration
MaxEntries int
// contains filtered or unexported fields
}
SourceLimiter bounds anonymous reads per source within a fixed window. A full table rejects new sources in O(1) until the earliest entry expires.
func (*SourceLimiter) Allow ¶ added in v0.2.0
func (l *SourceLimiter) Allow(source string) bool