Documentation ¶
Index ¶
- Constants
- Variables
- func Configure(l *goapp.Lifecycle, conf *config.Config)
- func DefaultHandlerStoreStream(node *Node, r io.Reader) (int64, error)
- func Deserialize(r io.Reader, data interface{}) error
- func DumpNode(node *Node)
- func GetSecurityAttributes(access []string) security.Attributes
- func GetValue(source interface{}, field string) interface{}
- func GetVaultMetadata(node *Node) (meta vault.VaultMetadata)
- func HandleError(req *http.Request, res http.ResponseWriter, err error)
- func HandlerLoad(handler Handler, data []byte, meta []byte, node *Node) error
- func InterfaceToJsonMessage(ntype string, data interface{}) json.RawMessage
- func NewRevisionError(message string) error
- func Serialize(w io.Writer, data interface{}) error
- type AccessOptions
- type AccessVoter
- type DatabaseNodeHandler
- type DownloadData
- type DownloadNodeHandler
- type Errors
- type Handler
- type HandlerCollection
- func (c HandlerCollection) Add(code string, h Handler)
- func (c HandlerCollection) Get(node *Node) Handler
- func (c HandlerCollection) GetByType(code string) Handler
- func (c HandlerCollection) GetTypes() []string
- func (c HandlerCollection) HasType(code string) bool
- func (c HandlerCollection) NewNode(t string) *Node
- type HandlerMetadata
- type HandlerViewMetadata
- type Handlers
- type HttpClient
- type Listener
- type LoadNodeHandler
- type MetadataHandler
- type MockedManager
- func (m *MockedManager) Find(uuid Reference) *Node
- func (m *MockedManager) FindBy(query sq.SelectBuilder, offset uint64, limit uint64) *list.List
- func (m *MockedManager) FindOneBy(query sq.SelectBuilder) *Node
- func (m *MockedManager) Move(uuid, parentUuid Reference) (int64, error)
- func (m *MockedManager) NewNode(t string) *Node
- func (m *MockedManager) Notify(channel string, payload string)
- func (m *MockedManager) Remove(query sq.SelectBuilder) error
- func (m *MockedManager) RemoveOne(node *Node) (*Node, error)
- func (m *MockedManager) Save(node *Node, revision bool) (*Node, error)
- func (m *MockedManager) SelectBuilder(options *SelectOptions) sq.SelectBuilder
- func (m *MockedManager) Validate(node *Node) (bool, Errors)
- type ModelEvent
- type Modules
- type Node
- type NodeData
- type NodeDeserializer
- type NodeManager
- type NodeMeta
- type NodeSerializer
- type PgNodeManager
- func (m *PgNodeManager) Find(uuid Reference) *Node
- func (m *PgNodeManager) FindBy(query sq.SelectBuilder, offset uint64, limit uint64) *list.List
- func (m *PgNodeManager) FindOneBy(query sq.SelectBuilder) *Node
- func (m *PgNodeManager) Move(uuid, parentUuid Reference) (int64, error)
- func (m *PgNodeManager) NewNode(t string) *Node
- func (m *PgNodeManager) Notify(channel string, payload string)
- func (m *PgNodeManager) Remove(query sq.SelectBuilder) error
- func (m *PgNodeManager) RemoveOne(node *Node) (*Node, error)
- func (m *PgNodeManager) Save(node *Node, newRevision bool) (*Node, error)
- func (m *PgNodeManager) SelectBuilder(options *SelectOptions) sq.SelectBuilder
- func (m *PgNodeManager) Validate(node *Node) (bool, Errors)
- type Reference
- type SelectOptions
- type Serializer
- type StoreStreamNodeHandler
- type Subscriber
- type SubscriberHander
- type ValidateNodeHandler
- type ViewHandler
- type ViewHandlerCollection
- type ViewMetadataHandler
- type ViewRequest
- type ViewResponse
Constants ¶
View Source
const ( PubSubListenContinue = 1 PubSubListenStop = 0 ProcessStatusInit = 0 // default value, nothing to do ProcessStatusReady = 1 // process is ready to be handled ProcessStatusUpdate = 2 // update in progress ProcessStatusDone = 3 // done, can also be set to init. Done also mean the related task cannot be restarted ProcessStatusError = -1 // an error occurs )
Variables ¶
View Source
var ( ErrValidation = errors.New("unable to validate data") ErrRevision = errors.New("wrong revision while saving") ErrNotFound = errors.New("unable to find the node") ErrInvalidReferenceFormat = errors.New("unable to parse the reference") ErrAlreadyDeleted = errors.New("unable to find the node") ErrNoStreamHandler = errors.New("no stream handler defined") ErrAccessForbidden = errors.New("access forbidden") ErrInvalidVersion = errors.New("wrong node version") ErrInvalidUuidLength = errors.New("invalid UUID length") )
View Source
var ( StatusNew = 0 StatusDraft = 1 StatusCompleted = 2 StatusValidated = 3 )
Functions ¶
func Deserialize ¶
func GetSecurityAttributes ¶
func GetSecurityAttributes(access []string) security.Attributes
func GetVaultMetadata ¶
func GetVaultMetadata(node *Node) (meta vault.VaultMetadata)
func HandleError ¶
func HandleError(req *http.Request, res http.ResponseWriter, err error)
func InterfaceToJsonMessage ¶
func InterfaceToJsonMessage(ntype string, data interface{}) json.RawMessage
func NewRevisionError ¶
Types ¶
type AccessOptions ¶
type AccessOptions struct { Token security.SecurityToken Roles security.Attributes }
func NewAccessOptions ¶
func NewAccessOptions(token security.SecurityToken, roles security.Attributes) *AccessOptions
func NewAccessOptionsFromToken ¶
func NewAccessOptionsFromToken(token security.SecurityToken) *AccessOptions
type AccessVoter ¶
type AccessVoter struct { }
func (*AccessVoter) Support ¶
func (a *AccessVoter) Support(v interface{}) bool
func (*AccessVoter) Vote ¶
func (a *AccessVoter) Vote(t security.SecurityToken, o interface{}, attrs security.Attributes) (result security.VoterResult, err error)
type DatabaseNodeHandler ¶
type DatabaseNodeHandler interface { PreUpdate(node *Node, m NodeManager) error PostUpdate(node *Node, m NodeManager) error PreInsert(node *Node, m NodeManager) error PostInsert(node *Node, m NodeManager) error }
type DownloadData ¶
type DownloadData struct { ContentType string Filename string CacheControl string Pragma string Expires string Stream func(node *Node, w io.Writer) }
func GetDownloadData ¶
func GetDownloadData() *DownloadData
type DownloadNodeHandler ¶
type DownloadNodeHandler interface {
GetDownloadData(node *Node) *DownloadData
}
type HandlerCollection ¶
func (HandlerCollection) Add ¶
func (c HandlerCollection) Add(code string, h Handler)
func (HandlerCollection) Get ¶
func (c HandlerCollection) Get(node *Node) Handler
func (HandlerCollection) GetByType ¶
func (c HandlerCollection) GetByType(code string) Handler
func (HandlerCollection) GetTypes ¶
func (c HandlerCollection) GetTypes() []string
func (HandlerCollection) HasType ¶
func (c HandlerCollection) HasType(code string) bool
func (HandlerCollection) NewNode ¶
func (c HandlerCollection) NewNode(t string) *Node
type HandlerMetadata ¶
type HandlerMetadata struct { Name string `json:"name"` Description string `json:"description"` Icon string `json:"icon"` Code string `json:"code"` Require []string `json:"require"` Authors []string `json:"authors"` }
func NewHandlerMetadata ¶
func NewHandlerMetadata() *HandlerMetadata
type HandlerViewMetadata ¶
type HandlerViewMetadata struct { Name string `json:"name"` Description string `json:"description"` Icon string `json:"icon"` Code string `json:"code"` Require []string `json:"require"` Authors []string `json:"authors"` }
func NewViewHandlerMetadata ¶
func NewViewHandlerMetadata() *HandlerViewMetadata
type HttpClient ¶
type HttpClient interface { Do(req *http.Request) (resp *http.Response, err error) Get(url string) (resp *http.Response, err error) Head(url string) (resp *http.Response, err error) Post(url string, bodyType string, body io.Reader) (resp *http.Response, err error) PostForm(url string, data url.Values) (resp *http.Response, err error) }
type Listener ¶
type Listener interface {
Handle(notification *pq.Notification, manager NodeManager) (int, error)
}
type LoadNodeHandler ¶
type MetadataHandler ¶
type MetadataHandler interface {
GetMetadata() *HandlerMetadata
}
type MockedManager ¶
func (*MockedManager) Find ¶
func (m *MockedManager) Find(uuid Reference) *Node
func (*MockedManager) FindBy ¶
func (m *MockedManager) FindBy(query sq.SelectBuilder, offset uint64, limit uint64) *list.List
func (*MockedManager) FindOneBy ¶
func (m *MockedManager) FindOneBy(query sq.SelectBuilder) *Node
func (*MockedManager) Move ¶
func (m *MockedManager) Move(uuid, parentUuid Reference) (int64, error)
func (*MockedManager) NewNode ¶
func (m *MockedManager) NewNode(t string) *Node
func (*MockedManager) Notify ¶
func (m *MockedManager) Notify(channel string, payload string)
func (*MockedManager) Remove ¶
func (m *MockedManager) Remove(query sq.SelectBuilder) error
func (*MockedManager) SelectBuilder ¶
func (m *MockedManager) SelectBuilder(options *SelectOptions) sq.SelectBuilder
type ModelEvent ¶
type ModelEvent struct { Subject string `json:"subject"` Action string `json:"action"` Type string `json:"type"` Revision int `json:"revision"` Date time.Time `json:"date"` Extra string `json:"extra"` Name string `json:"name"` NewRevision bool `json:"new_revision"` }
func CreateModelEvent ¶
func CreateModelEvent(notification *pq.Notification) *ModelEvent
type Node ¶
type Node struct { Id int `json:"-"` Uuid Reference `json:"uuid"` Type string `json:"type"` Name string `json:"name"` Slug string `json:"slug"` Path string `json:"path"` Data interface{} `json:"data"` Meta interface{} `json:"meta"` Status int `json:"status"` Weight int `json:"weight"` Revision int `json:"revision"` Version int `json:"version"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Enabled bool `json:"enabled"` Deleted bool `json:"deleted"` Parents []Reference `json:"parents"` UpdatedBy Reference `json:"updated_by"` CreatedBy Reference `json:"created_by"` ParentUuid Reference `json:"parent_uuid"` SetUuid Reference `json:"set_uuid"` Source Reference `json:"source"` Modules Modules `json:"modules"` Access []string `json:"access"` // key => roles required to access the nodes }
type NodeManager ¶
type NodeManager interface { SelectBuilder(option *SelectOptions) sq.SelectBuilder FindBy(query sq.SelectBuilder, offset uint64, limit uint64) *list.List FindOneBy(query sq.SelectBuilder) *Node Find(uuid Reference) *Node Remove(query sq.SelectBuilder) error RemoveOne(node *Node) (*Node, error) Save(node *Node, revision bool) (*Node, error) Notify(channel string, payload string) NewNode(t string) *Node Validate(node *Node) (bool, Errors) Move(uuid, parent Reference) (int64, error) }
type PgNodeManager ¶
type PgNodeManager struct { Logger *log.Logger Handlers Handlers Db *sql.DB ReadOnly bool Prefix string }
func (*PgNodeManager) Find ¶
func (m *PgNodeManager) Find(uuid Reference) *Node
func (*PgNodeManager) FindBy ¶
func (m *PgNodeManager) FindBy(query sq.SelectBuilder, offset uint64, limit uint64) *list.List
func (*PgNodeManager) FindOneBy ¶
func (m *PgNodeManager) FindOneBy(query sq.SelectBuilder) *Node
func (*PgNodeManager) Move ¶
func (m *PgNodeManager) Move(uuid, parentUuid Reference) (int64, error)
func (*PgNodeManager) NewNode ¶
func (m *PgNodeManager) NewNode(t string) *Node
func (*PgNodeManager) Notify ¶
func (m *PgNodeManager) Notify(channel string, payload string)
func (*PgNodeManager) Remove ¶
func (m *PgNodeManager) Remove(query sq.SelectBuilder) error
func (*PgNodeManager) Save ¶
func (m *PgNodeManager) Save(node *Node, newRevision bool) (*Node, error)
func (*PgNodeManager) SelectBuilder ¶
func (m *PgNodeManager) SelectBuilder(options *SelectOptions) sq.SelectBuilder
type Reference ¶
func GetEmptyReference ¶
func GetEmptyReference() Reference
func GetReference ¶
func GetReferenceFromString ¶
func GetRootReference ¶
func GetRootReference() Reference
func (*Reference) CleanString ¶
func (*Reference) MarshalJSON ¶
func (*Reference) UnmarshalJSON ¶
type SelectOptions ¶
func NewSelectOptions ¶
func NewSelectOptions() *SelectOptions
type Serializer ¶
type Serializer struct { Handlers Handlers // contains filtered or unexported fields }
func NewSerializer ¶
func NewSerializer() *Serializer
func (*Serializer) AddDeserializer ¶
func (s *Serializer) AddDeserializer(name string, f NodeDeserializer)
func (*Serializer) AddSerializer ¶
func (s *Serializer) AddSerializer(name string, f NodeSerializer)
func (*Serializer) Deserialize ¶
func (s *Serializer) Deserialize(r io.Reader, o interface{}) error
type StoreStreamNodeHandler ¶
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
func NewSubscriber ¶
func NewSubscriber(conninfo string, logger *log.Logger) *Subscriber
func (*Subscriber) ListenMessage ¶
func (s *Subscriber) ListenMessage(name string, handler SubscriberHander)
func (*Subscriber) Register ¶
func (s *Subscriber) Register()
func (*Subscriber) Stop ¶
func (s *Subscriber) Stop()
type SubscriberHander ¶
type SubscriberHander func(notification *pq.Notification) (int, error)
type ValidateNodeHandler ¶
type ValidateNodeHandler interface {
Validate(node *Node, m NodeManager, e Errors)
}
type ViewHandler ¶
type ViewHandler interface { Support(node *Node, request *ViewRequest, response *ViewResponse) bool Execute(node *Node, request *ViewRequest, response *ViewResponse) error }
type ViewHandlerCollection ¶
type ViewHandlerCollection map[string]ViewHandler
func (ViewHandlerCollection) Add ¶
func (c ViewHandlerCollection) Add(code string, h ViewHandler)
func (ViewHandlerCollection) Get ¶
func (c ViewHandlerCollection) Get(node *Node) ViewHandler
func (ViewHandlerCollection) GetByType ¶
func (c ViewHandlerCollection) GetByType(code string) ViewHandler
func (ViewHandlerCollection) GetTypes ¶
func (c ViewHandlerCollection) GetTypes() []string
func (ViewHandlerCollection) HasType ¶
func (c ViewHandlerCollection) HasType(code string) bool
type ViewMetadataHandler ¶
type ViewMetadataHandler interface {
GetViewMetadata() *HandlerViewMetadata
}
type ViewRequest ¶
type ViewResponse ¶
type ViewResponse struct { StatusCode int Template string Context template.Context HttpResponse http.ResponseWriter ContentType string }
func NewViewResponse ¶
func NewViewResponse(res http.ResponseWriter) *ViewResponse
func (*ViewResponse) Add ¶
func (r *ViewResponse) Add(name string, v interface{}) *ViewResponse
func (*ViewResponse) Set ¶
func (r *ViewResponse) Set(code int, template string) *ViewResponse
Click to show internal directories.
Click to hide internal directories.