Documentation
¶
Index ¶
- Constants
- func AdminHomeURL(r *http.Request) string
- func Breadcrumbs(breadcrumbs []Breadcrumb) hb.TagInterface
- func Endpoint(r *http.Request) string
- func ErrorAlert(message string) string
- func FileManagerURL(r *http.Request) string
- func Layout(w http.ResponseWriter, r *http.Request, webpageTitle, webpageHtml string, ...) string
- func LogAdminURL(r *http.Request) string
- func URL(endpoint string, controller string, params map[string]string) string
- func URLR(r *http.Request, controller string, params map[string]string) string
- type Breadcrumb
- type Links
- type UiBase
- type UiConfig
- type UiInterface
Constants ¶
const (
CONTROLLER_LOG_MANAGER = "log-manager"
)
Controller names used in the ?controller= query parameter
const CatchAll = "/*"
CatchAll is the catch-all route suffix
const ERROR_LOGGER_IS_NIL = "logger cannot be nil"
const ERROR_STORE_IS_NIL = "store cannot be nil"
Error messages
const KeyAdminHomeURL = "admin_home_url"
const KeyEndpoint = "endpoint"
Context keys for config values injected by Handle()
const KeyFileManagerURL = "file_manager_url"
const KeyLogAdminURL = "log_admin_url"
Variables ¶
This section is empty.
Functions ¶
func AdminHomeURL ¶
AdminHomeURL returns the admin home URL from request context
func Breadcrumbs ¶
func Breadcrumbs(breadcrumbs []Breadcrumb) hb.TagInterface
Breadcrumbs renders a breadcrumb navigation from the given items
func ErrorAlert ¶
ErrorAlert returns an inline HTML error alert for the given message. This replaces the former ToFlashError flash-message pattern, which required a cache store and a /flash route handler that did not exist.
func FileManagerURL ¶
FileManagerURL returns the file manager URL from request context
func Layout ¶
func Layout(w http.ResponseWriter, r *http.Request, webpageTitle, webpageHtml string, options struct { Styles []string StyleURLs []string Scripts []string ScriptURLs []string }) string
Layout is the default layout renderer. It builds a complete HTML page using hb.NewWebpage() with Bootstrap + Vue CDN, matching the shopadmin/blogadmin pattern. If a FuncLayout is provided in AdminOptions, it takes precedence over this default.
func LogAdminURL ¶
LogAdminURL returns the log admin base URL from request context
Types ¶
type Breadcrumb ¶
Breadcrumb represents a single breadcrumb navigation item
type Links ¶
type Links struct {
// contains filtered or unexported fields
}
Links provides URL helpers for logadmin controllers. The base URL is read from request context (injected by Handle()), not hardcoded. This follows the shopadmin/blogadmin pattern.
func NewLinks ¶
NewLinks creates a Links helper with the given base URL. If baseURL is empty, defaults to "/admin/logs".
func NewLinksFromRequest ¶
NewLinksFromRequest creates a Links helper using the log admin URL from the request context.
type UiBase ¶
type UiBase struct {
StoreField logstore.StoreInterface
LoggerField *slog.Logger
LayoutField func(w http.ResponseWriter, r *http.Request, webpageTitle, webpageHtml string, options struct {
Styles []string
StyleURLs []string
Scripts []string
ScriptURLs []string
}) string
}
UiBase is a base struct that implements shared.UiInterface. Subcontroller ui structs can embed this to get the Store(), Logger(), and Layout() methods for free, following the shopadmin/blogadmin pattern.
func (UiBase) Store ¶
func (u UiBase) Store() logstore.StoreInterface
type UiConfig ¶
type UiConfig struct {
Store logstore.StoreInterface
Logger *slog.Logger
Layout func(w http.ResponseWriter, r *http.Request, webpageTitle, webpageHtml string, options struct {
Styles []string
StyleURLs []string
Scripts []string
ScriptURLs []string
}) string
}
UiConfig holds the dependencies passed to subcontroller UI factories. The Layout function uses an anonymous struct for options to match shopadmin/blogadmin exactly, allowing consumers to reuse their existing layout function for logadmin.
type UiInterface ¶
type UiInterface interface {
Store() logstore.StoreInterface
Logger() *slog.Logger
Layout(w http.ResponseWriter, r *http.Request, webpageTitle, webpageHtml string, options struct {
Styles []string
StyleURLs []string
Scripts []string
ScriptURLs []string
}) string
}
UiInterface defines the methods every subcontroller UI must implement. This follows the shopadmin/blogadmin pattern.