Documentation ¶
Index ¶
- Constants
- Variables
- func AddHook(name string, f HookFunc) error
- func CallHook(name string, param interface{}) (returns []interface{}, err error)
- func CreateEndpoint(path string, handler EndpointHandler) error
- func CreateLayout(name string, tmpl template.Template, parent string)
- func GetConf(key string, def interface{}) (value interface{}, err error)
- func Load(name string) (err error)
- func NewHook(name string) error
- func Render(layout, content, title, tags, author, desc string, ...) (result string, err error)
- func RunLayout(name string, content template.HTML, context map[string]interface{}) (result string, err error)
- func Serve(address string) error
- type Component
- type ComponentKind
- type Endpoint
- type EndpointHandler
- type ExtensionHook
- type HookFunc
- type ResponseData
Constants ¶
const ( // ApplicationComponent is the kind of an application providing HTTP endpoints. ApplicationComponent = iota // ExtensionComponent is the kind of an extension installing hooks into applications and the system. ExtensionComponent = iota )
Variables ¶
var Errors = map[int]string{
404: "gitlab.com/alexbuzzbee/concept.Error404",
500: "gitlab.com/alexbuzzbee/concept.Error500",
}
Errors contains the server's built-in error pages.
Functions ¶
func CallHook ¶
CallHook invokes all the functions in a hook, returning a slice of their return values.
func CreateEndpoint ¶
func CreateEndpoint(path string, handler EndpointHandler) error
CreateEndpoint creates and sets up an endpoint.
func CreateLayout ¶
CreateLayout creates and registers a layout. A layout's name should be a fully-qualified Go package name (e.g. gitlab.com/alexbuzzbee/concept-admin) followed by a period and the unqualified name (e.g. ConfigPage).
func Render ¶
func Render(layout, content, title, tags, author, desc string, extra map[string]interface{}) (result string, err error)
Render renders a page using a layout with a title, author, description, some tags, and optionally extra data.
Types ¶
type Component ¶
type Component struct { // The name identifies the component. It should be a fully-qualified Go package name (e.g. gitlab.com/alexbuzzbee/concept-admin) followed by a period and the unqualified name (e.g. App). Name string Kind ComponentKind Exported []interface{} }
A Component provides new functionality to Concept.
type Endpoint ¶
type Endpoint struct { // The Path is the endpoint's path; it may contain wildcards. Path string Handler EndpointHandler }
An Endpoint is an actual endpoint.
type EndpointHandler ¶
type EndpointHandler func(path string, params map[string][]string) (content string, extra ResponseData, err error)
An EndpointHandler is a function that handles endpoints.
type ExtensionHook ¶
An ExtensionHook is a hook exported by an extension.
type HookFunc ¶
type HookFunc func(param interface{}) interface{}
A HookFunc is a function that can be put into a hook.
type ResponseData ¶
A ResponseData contains extra information about a dispatch result besides its content and/or error.
func DispatchEndpoint ¶
func DispatchEndpoint(requestedPath string, params map[string][]string) (content string, extra ResponseData, err error)
DispatchEndpoint calls the correct endpoint handler for the specified path.
func DispatchError ¶
func DispatchError(path string, code int, err error) (content string, extra ResponseData, _err error)
DispatchError renders an error page.