Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyTemplate(templateStr string, data map[string]interface{}) (string, []error)
- func CloneMap(source map[string]interface{}) map[string]interface{}
- func DecodeWithBasicHooks(instance interface{}, config interface{}) []error
- func EncloseContent(enclose string, content string) string
- func ExtractHxData(r *http.Request) (map[string]interface{}, error)
- func GetLogger() *zap.SugaredLogger
- func HyperScriptErrorHash(s string) string
- func Init_configuration()
- func IsJSONContent(contentType string) bool
- func IsMultipartForm(contentType string) bool
- func JoinHeaderValues(values []string) string
- func JoinTestCode(hyperbricks string, propertyTest string) []string
- func RenderAllowedAttributes(attributes map[string]interface{}, allowed []string) string
- func RenderValidationWarnings(warnings []string) string
- func RenderValidationWarningsWithPath(warnings []string, hyperbrickspath []string) string
- func RenderWarning(warning string) string
- func SortedUniqueKeys(m map[string]interface{}) []string
- func StructToMap(data interface{}) map[string]interface{}
- func StructToMapRecursive(input interface{}) map[string]interface{}
- func ToMap(value interface{}) (map[string]interface{}, bool)
- func TrimWrap(content, html string) string
- func Validate(config interface{}) []error
- func WriteToFile(filename, content string) error
- type CacheTime
- type Component
- type ComponentError
- type ComponentRenderer
- type ComponentRendererConfig
- type Composite
- type CompositeError
- type CompositeRenderer
- type CompositeRendererConfig
- type Config
- type DebugConfig
- type DevelopmentConfig
- type ExtendedRendererConfig
- type LiveConfig
- type LoggerConfig
- type Meta
- type PathKeyer
- type PluginConfig
- type PluginRenderer
- type RenderFunc
- type Renderer
- type ServerConfig
Constants ¶
const ( LIVE_MODE string = "live" DEBUG_MODE string = "debug" DEVELOPMENT_MODE string = "development" )
Variables ¶
var ( Write bool Outputpath string = "../../cmd/hyperbricks-docs/hyperbricks-examples/" )
var (
Module string
)
Functions ¶
func ApplyTemplate ¶
applyTemplate generates output based on the provided template and API data.
func DecodeWithBasicHooks ¶
func DecodeWithBasicHooks(instance interface{}, config interface{}) []error
func EncloseContent ¶
EncloseContent encloses the given content with the specified enclose string. The enclose string can be a single tag or a pair separated by '|'.
func ExtractHxData ¶
ExtractHxData extracts headers, form data, JSON payloads, and query parameters from an HTTP request.
func GetLogger ¶
func GetLogger() *zap.SugaredLogger
GetLogger returns the singleton SugaredLogger instance
func HyperScriptErrorHash ¶
func Init_configuration ¶
func Init_configuration()
func IsJSONContent ¶
IsJSONContent checks if the Content-Type is application/json.
func IsMultipartForm ¶
IsMultipartForm checks if the Content-Type is multipart/form-data.
func JoinHeaderValues ¶
JoinHeaderValues concatenates multiple header values into a single string separated by commas.
func JoinTestCode ¶
Helper function to combine the main configuration string with a property-specific test case.
func RenderAllowedAttributes ¶
RenderAllowedAttributes filters and formats the allowed attributes for rendering in a consistent order.
func RenderWarning ¶
func SortedUniqueKeys ¶
SortedKeys returns the keys of the map sorted numerically or lexicographically. It caches the sorted keys for maps with the same set of keys. This uses TreeMap, is 5 times faster and uses 53 times less memory than the non-TreeMap
func StructToMap ¶
func StructToMap(data interface{}) map[string]interface{}
Helper function to convert a struct to a map for easy validation in test cases.
func StructToMapRecursive ¶
func StructToMapRecursive(input interface{}) map[string]interface{}
func WriteToFile ¶
Helper function to write test outputs to a file for documentation purposes.
Types ¶
type CacheTime ¶
CacheTime manages cache duration.
func (*CacheTime) UnmarshalText ¶
UnmarshalText allows mapstructure to decode CacheTime.
type Component ¶
type Component = ComponentRendererConfig
type ComponentError ¶
type ComponentError struct {
Err string // A descriptive error message
Key string // Key of the component
Path string // Path of the component in the hierarchy
Rejected bool // Rendering is rejected
Type string // Which HyperBricks type?
Level string // INFO, WARNING, otherwise ERROR
}
ComponentError represents an error associated with a component.
func HyperbricksDecodeError ¶
func HyperbricksDecodeError(err string, path string, key string) (string, []ComponentError)
returns a anchor with error
func (ComponentError) Error ¶
func (e ComponentError) Error() string
Error implements the error interface for ComponentError.
type ComponentRenderer ¶
type ComponentRenderer interface {
Renderer
}
type ComponentRendererConfig ¶
type ComponentRendererConfig struct {
Meta `mapstructure:",squash"` // Embedding RendererConfig
ExtraAttributes map[string]interface{} `mapstructure:"attributes" description:"Extra attributes like id, data-role, data-action"`
Enclose string `mapstructure:"enclose" description:"The enclosing HTML element for the header divided by |"`
}
Basic config for ComponentRenderers
func (ComponentRendererConfig) GetConfigType ¶
func (c ComponentRendererConfig) GetConfigType() string
func (ComponentRendererConfig) GetKey ¶
func (c ComponentRendererConfig) GetKey() string
func (ComponentRendererConfig) GetPath ¶
func (c ComponentRendererConfig) GetPath() string
type Composite ¶
type Composite = CompositeRendererConfig
type CompositeError ¶
type CompositeError struct {
Err string // A descriptive error message
Key string // Key of the component
Path string // Path of the component in the hierarchy
Rejected bool // Rendering is rejected
Type string // Which HyperBricks type?
Level string // INFO, WARNING, otherwise ERROR
}
ComponentError represents an error associated with a component.
func (CompositeError) Error ¶
func (e CompositeError) Error() string
Error implements the error interface for ComponentError.
type CompositeRenderer ¶
type CompositeRenderer interface {
Renderer
}
CompositeRenderer extends Renderer to handle composite rendering (itself and children).
type CompositeRendererConfig ¶
type Config ¶
type Config struct {
Mode string `mapstructure:"mode"`
Logger LoggerConfig `mapstructure:"logger"`
Server ServerConfig `mapstructure:"server"`
Development DevelopmentConfig `mapstructure:"development"`
Debug DebugConfig `mapstructure:"debug"`
Live LiveConfig `mapstructure:"live"`
Directories map[string]string `mapstructure:"directories"`
}
Config structure with default values.
func GetHyperBricksConfiguration ¶
func GetHyperBricksConfiguration() *Config
GetHyperBricksConfiguration returns the singleton instance of the Config.
type DebugConfig ¶
type DebugConfig struct {
// contains filtered or unexported fields
}
type DevelopmentConfig ¶
type ExtendedRendererConfig ¶
Example Extended struct
type LiveConfig ¶
type LiveConfig struct {
CacheTime CacheTime `mapstructure:"cache"`
}
type LoggerConfig ¶
LoggerConfig with defaults.
type Meta ¶
type Meta struct {
ConfigType string `mapstructure:"@type" exclude:"true" description:"Identification for renderer"`
ConfigCategory string
Key string `mapstructure:"key" exclude:"true"`
Path string `mapstructure:"path" exclude:"true"`
File string `mapstructure:"file" exclude:"true"`
}
GENERIC CONFIG FIELDS
type PluginConfig ¶
type PluginConfig map[string]interface{}
PluginConfig is a generic configuration map for plugins.
type PluginRenderer ¶
RenderPlugin defines the interface for dynamic plugins.
type RenderFunc ¶
RenderFunc defines the signature for the render callback.
type ServerConfig ¶
ServerConfig with defaults.