Documentation
¶
Overview ¶
Package funcadmin provides a standalone admin interface for the funcstore package, 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/blogadmin.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrStoreRequired is returned when Store is not provided ErrStoreRequired = errors.New("FaaS store is required") // ErrLoggerRequired is returned when Logger is not provided ErrLoggerRequired = errors.New("logger is required") )
Common errors
Functions ¶
This section is empty.
Types ¶
type AdminInterface ¶
type AdminInterface interface {
Handle(w http.ResponseWriter, r *http.Request)
}
AdminInterface defines the interface for the FaaS admin
func New ¶
func New(opts AdminOptions) (AdminInterface, error)
New creates a new FaaS admin instance. Returns ErrStoreRequired if Store is nil, ErrLoggerRequired if Logger is nil.
type AdminOptions ¶
type AdminOptions struct {
// Store is the funcstore.StoreInterface (required)
Store funcstore.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.
FuncLayout func(w http.ResponseWriter, r *http.Request, title string, body string, options struct {
Styles []string
StyleURLs []string
Scripts []string
ScriptURLs []string
}) string
// AdminHomeURL is the URL for the admin home page (default: "/admin")
AdminHomeURL string
// FaaSAdminURL is the base URL for FaaS admin (default: "/admin/FaaS")
FaaSAdminURL string
// FileManagerURL is the URL for the file manager (optional)
FileManagerURL string
// AuthUserID returns the authenticated user ID from the request.
// If it returns "", the user is treated as unauthenticated.
AuthUserID func(r *http.Request) string
}
AdminOptions contains all dependencies and configuration for the FaaS admin.
Store and Logger are required. FuncLayout is optional — if nil, a default bare-bones HTML page is used (Bootstrap + Vue CDN).