Documentation
¶
Overview ¶
Package taskadmin provides a standalone task admin interface following the folder-per-controller pattern. Each controller is in its own subfolder and handles its own views and AJAX data.
This module is modeled on github.com/dracory/shopadmin and was extracted from github.com/dracory/taskstore/admin.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrStoreRequired = errors.New("store is required") ErrLoggerRequired = errors.New("logger is required") )
Functions ¶
This section is empty.
Types ¶
type AdminInterface ¶
type AdminInterface interface {
Handle(w http.ResponseWriter, r *http.Request)
}
AdminInterface defines the interface for the task admin
func New ¶
func New(opts AdminOptions) (AdminInterface, error)
New creates a new task admin instance. Returns ErrStoreRequired if Store is nil, ErrLoggerRequired if Logger is nil.
type AdminOptions ¶
type AdminOptions struct {
// Store is the taskstore.StoreInterface (required)
Store taskstore.StoreInterface
// Logger is required
Logger *slog.Logger
// FuncLayout is an optional function to render the admin interface
// inside your own layout (branding, menus, etc.). It receives the
// request and response writer so the host project can access request
// context (auth user, locale, etc.) when rendering the layout.
// If nil, a default bare-bones HTML page is used (Bootstrap CDN).
FuncLayout shared.FuncLayout
// AdminHomeURL is the URL for the admin home page (default: "/admin")
AdminHomeURL string
// TaskAdminURL is the base URL for the task admin (default: "/admin/task")
TaskAdminURL string
// AuthUserID returns the authenticated user ID from the request.
// If it returns "", the user is treated as unauthenticated.
// Optional — nil disables the auth check.
AuthUserID func(r *http.Request) string
}
AdminOptions contains all dependencies and configuration for the task admin.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package testutils provides shared test helpers for taskadmin: an in-memory SQLite task store and a mock Layout implementation.
|
Package testutils provides shared test helpers for taskadmin: an in-memory SQLite task store and a mock Layout implementation. |