Documentation ¶
Index ¶
- Constants
- Variables
- func Callback(section string, w http.ResponseWriter, r *http.Request) error
- func Command(section string, ctx *Context, w http.ResponseWriter, r *http.Request) bool
- func List() map[string]Provider
- func Refresh(section string, ctx *Context, config, data string) (string, bool)
- func Register(name string, p Provider)
- func Render(section string, ctx *Context, config, data string) (string, bool)
- func WriteEmpty(w http.ResponseWriter)
- func WriteError(w http.ResponseWriter, section string, err error)
- func WriteForbidden(w http.ResponseWriter)
- func WriteJSON(w http.ResponseWriter, v interface{})
- func WriteMarshalError(w http.ResponseWriter, err error)
- func WriteMessage(w http.ResponseWriter, section, msg string)
- func WriteString(w http.ResponseWriter, data string)
- type Context
- type Provider
- type TypeMeta
Constants ¶
const SecretReplacement = "********"
SecretReplacement is a constant used to replace secrets in data-structures when required. 8 stars.
Variables ¶
var ErrNoSecrets = errors.New("no secrets in database")
ErrNoSecrets is returned if no secret is found in the database.
Functions ¶
func Callback ¶
Callback passes parameters to the given section callback, the returned error indicates success.
func Command ¶
Command passes parameters to the given section id, the returned bool indicates success.
func Render ¶
Render runs that operation for the given section id, the returned bool indicates success.
func WriteEmpty ¶
func WriteEmpty(w http.ResponseWriter)
WriteEmpty returns just OK to HTTP response.
func WriteError ¶
func WriteError(w http.ResponseWriter, section string, err error)
WriteError write given error to HTTP response.
func WriteForbidden ¶
func WriteForbidden(w http.ResponseWriter)
WriteForbidden write 403 to HTTP response.
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, v interface{})
WriteJSON writes data as JSON to HTTP response.
func WriteMarshalError ¶
func WriteMarshalError(w http.ResponseWriter, err error)
WriteMarshalError write JSON marshalling error to HTTP response.
func WriteMessage ¶
func WriteMessage(w http.ResponseWriter, section, msg string)
WriteMessage write string to HTTP response.
func WriteString ¶
func WriteString(w http.ResponseWriter, data string)
WriteString writes string tp HTTP response.
Types ¶
type Context ¶
Context describes the environment the section code runs in
func NewContext ¶
NewContext is a convenience function.
func (*Context) GetSecrets ¶
GetSecrets for the current context user/org. For example (see SaveSecrets example): thisContext.GetSecrets("mysecret") JSONpath format is defined at https://dev.mysql.com/doc/refman/5.7/en/json-path-syntax.html . An empty JSONpath returns the whole JSON object, as JSON. Errors return the empty string.
func (*Context) MarshalSecrets ¶
MarshalSecrets to the database. Parameter the same as for json.Marshal().
func (*Context) SaveSecrets ¶
SaveSecrets for the current user/org combination. The secrets must be in the form of a JSON format string, for example `{"mysecret":"lover"}`. An empty string signifies no valid secrets for this user/org combination. Note that this function can only be called within the Command method of a section.
func (*Context) UnmarshalSecrets ¶
UnmarshalSecrets from the database. Parameter the same as for "v" in json.Unmarshal().
type Provider ¶
type Provider interface { Meta() TypeMeta // Meta returns section details Command(ctx *Context, w http.ResponseWriter, r *http.Request) // Command is general-purpose method that can return data to UI Render(ctx *Context, config, data string) string // Render converts section data into presentable HTML Refresh(ctx *Context, config, data string) string // Refresh returns latest data }
Provider represents a 'page' in a document.
type TypeMeta ¶
type TypeMeta struct { ID string `json:"id"` Order int `json:"order"` ContentType string `json:"contentType"` Title string `json:"title"` Description string `json:"description"` Preview bool `json:"preview"` // coming soon! Callback func(http.ResponseWriter, *http.Request) error `json:"-"` }
TypeMeta details a "smart section" that represents a "page" in a document.
func GetSectionMeta ¶
func GetSectionMeta() []TypeMeta
GetSectionMeta returns a list of smart sections.
func (*TypeMeta) ConfigHandle ¶
ConfigHandle returns the key name for database config table