Documentation
¶
Overview ¶
Package admin implements a single-endpoint RPC-style Admin API for Madmail.
Architecture: All requests are POST /api/admin with a JSON body:
{
"method": "GET|POST|PUT|DELETE|PATCH",
"resource": "/admin/status",
"headers": { "Authorization": "Bearer <token>" },
"body": {}
}
Response format:
{
"status": 200,
"resource": "/admin/status",
"body": { ... },
"error": null
}
This design makes the API easier to hide behind reverse proxies, firewalls, or custom auth layers — one port, one path, one handler.
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 is the main Admin API handler.
func NewHandler ¶
NewHandler creates a new Admin API handler.
func (*Handler) Register ¶
func (h *Handler) Register(path string, handler ResourceHandler)
Register adds a resource handler for the given path.
type Request ¶
type Request struct {
Method string `json:"method"`
Resource string `json:"resource"`
Headers map[string]string `json:"headers"`
Body json.RawMessage `json:"body"`
}
Request is the JSON-RPC style request envelope.
type ResourceHandler ¶
type ResourceHandler func(method string, body json.RawMessage) (interface{}, int, error)
ResourceHandler is the signature for individual resource handlers. It receives the parsed request and returns a response body and status code.
Click to show internal directories.
Click to hide internal directories.