community: Index | Files

package provider

import ""


Package Files



const SecretReplacement = "********"

SecretReplacement is a constant used to replace secrets in data-structures when required. 8 stars.


var ErrNoSecrets = errors.New("no secrets in database")

ErrNoSecrets is returned if no secret is found in the database.

func Callback Uses

func Callback(section string, rt *env.Runtime, store *store.Store, w http.ResponseWriter, r *http.Request) error

Callback passes parameters to the given section callback, the returned error indicates success.

func Command Uses

func Command(section string, ctx *Context, w http.ResponseWriter, r *http.Request) bool

Command passes parameters to the given section id, the returned bool indicates success.

func List Uses

func List() map[string]Provider

List returns available types

func Refresh Uses

func Refresh(section string, ctx *Context, config, data string) (string, bool)

Refresh returns the latest data for a section.

func Register Uses

func Register(name string, p Provider)

Register makes document section type available

func Render Uses

func Render(section string, ctx *Context, config, data string) (string, bool)

Render runs that operation for the given section id, the returned bool indicates success.

func WriteEmpty Uses

func WriteEmpty(w http.ResponseWriter)

WriteEmpty returns just OK to HTTP response.

func WriteError Uses

func WriteError(w http.ResponseWriter, section string, err error)

WriteError write given error to HTTP response.

func WriteForbidden Uses

func WriteForbidden(w http.ResponseWriter)

WriteForbidden write 403 to HTTP response.

func WriteJSON Uses

func WriteJSON(w http.ResponseWriter, v interface{})

WriteJSON writes data as JSON to HTTP response.

func WriteMarshalError Uses

func WriteMarshalError(w http.ResponseWriter, err error)

WriteMarshalError write JSON marshalling error to HTTP response.

func WriteMessage Uses

func WriteMessage(w http.ResponseWriter, section, msg string)

WriteMessage write string to HTTP response.

func WriteString Uses

func WriteString(w http.ResponseWriter, data string)

WriteString writes string tp HTTP response.

type Context Uses

type Context struct {
    OrgID  string
    UserID string

    Request domain.RequestContext
    // contains filtered or unexported fields

Context describes the environment the section code runs in

func NewContext Uses

func NewContext(orgid, userid string, ctx domain.RequestContext) *Context

NewContext is a convenience function.

func (*Context) GetSecrets Uses

func (c *Context) GetSecrets(JSONpath string, s *store.Store) string

GetSecrets for the current context user/org. For example (see SaveSecrets example): thisContext.GetSecrets("mysecret") JSONpath format is defined at . An empty JSONpath returns the whole JSON object, as JSON. Errors return the empty string.

func (*Context) MarshalSecrets Uses

func (c *Context) MarshalSecrets(sec interface{}, s *store.Store) error

MarshalSecrets to the database. Parameter the same as for json.Marshal().

func (*Context) SaveSecrets Uses

func (c *Context) SaveSecrets(JSONobj string, s *store.Store) error

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 Uses

func (c *Context) UnmarshalSecrets(v interface{}, s *store.Store) error

UnmarshalSecrets from the database. Parameter the same as for "v" in json.Unmarshal().

type Provider Uses

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 Uses

type TypeMeta struct {
    ID          string                                                                     `json:"id"`
    Order       int                                                                        `json:"order"`
    ContentType string                                                                     `json:"contentType"`
    PageType    string                                                                     `json:"pageType"`
    Title       string                                                                     `json:"title"`
    Description string                                                                     `json:"description"`
    Retired     bool                                                                       `json:"retired"` // no new inserts of this type, just edits
    Preview     bool                                                                       `json:"preview"` // coming soon!
    Callback    func(*env.Runtime, *store.Store, http.ResponseWriter, *http.Request) error `json:"-"`

TypeMeta details a "smart section" that represents a "page" in a document.

func GetSectionMeta Uses

func GetSectionMeta() []TypeMeta

GetSectionMeta returns a list of smart sections.

func (*TypeMeta) ConfigHandle Uses

func (t *TypeMeta) ConfigHandle() string

ConfigHandle returns the key name for database config table

Package provider imports 9 packages (graph) and is imported by 30 packages. Updated 2019-03-03. Refresh now. Tools for package owners.