admin

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package admin provides an HTTP management surface for mailbox service operations. Mount Handler at any path prefix in your HTTP mux:

mux.Handle("/admin/", http.StripPrefix("/admin", admin.NewHandler(svc, admin.WithAuthFunc(myAuth))))

Authentication is required: provide WithAuthFunc or WithAllowAll (for trusted environments).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler exposes mailbox service management operations over HTTP.

func NewHandler

func NewHandler(svc mailbox.Service, opts ...Option) (*Handler, error)

NewHandler creates a new Handler for the given service. Returns an error if svc is nil, or if neither WithAuthFunc nor WithAllowAll is provided.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

type Option

type Option func(*options)

Option configures a Handler.

func WithAllowAll added in v0.7.8

func WithAllowAll() Option

WithAllowAll explicitly opts out of authentication for the admin handler. Use this only in trusted environments (e.g., behind a gateway that handles auth, or in tests). In production, prefer WithAuthFunc.

func WithAuthFunc

func WithAuthFunc(fn func(r *http.Request) bool) Option

WithAuthFunc sets an authorization function. Each request is passed to the function before handling; a false return results in a 403 response.

func WithLogger

func WithLogger(l *slog.Logger) Option

WithLogger sets a custom logger. Default is slog.Default().

Jump to

Keyboard shortcuts

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