rest

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2018 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package rest is an implementation of AssetSource which fetches assets from a REST server. It maintains a cache which can also be preloaded with assets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetCache

type AssetCache struct {
	// contains filtered or unexported fields
}

AssetCache fetches and caches assets for the engine

func NewAssetCache

func NewAssetCache(maxSize int64, pruneItems int) *AssetCache

NewAssetCache creates a new asset cache

func (*AssetCache) Include

func (c *AssetCache) Include(data json.RawMessage) error

Include loads assets from the given raw JSON into the cache

func (*AssetCache) Shutdown

func (c *AssetCache) Shutdown()

Shutdown shuts down this asset cache

type AssetReader

type AssetReader func(data json.RawMessage) (interface{}, error)

AssetReader is a function capable of reading an asset type from JSON

type AssetType

type AssetType string

AssetType is the unique slug for an asset type

type MockServerSource

type MockServerSource struct {
	ServerSource
	// contains filtered or unexported fields
}

MockServerSource is a version of the server source which allows requests to be mocked for testing

func NewMockServerSource

func NewMockServerSource(cache *AssetCache) *MockServerSource

NewMockServerSource creates a new mocked asset server for testing

func (*MockServerSource) MarshalJSON

func (s *MockServerSource) MarshalJSON() ([]byte, error)

MarshalJSON marshals this mock asset server into JSON

func (*MockServerSource) MockResponse

func (s *MockServerSource) MockResponse(url string, response json.RawMessage)

MockResponse creates a new mocked response for the given URL

func (*MockServerSource) MockedRequests

func (s *MockServerSource) MockedRequests() []string

MockedRequests returns all mocked requests made so far

type ServerSource

type ServerSource struct {
	// contains filtered or unexported fields
}

ServerSource is an asset source which fetches assets from a server and caches them

func NewServerSource

func NewServerSource(authToken string, typeURLs map[AssetType]string, httpClient *utils.HTTPClient, cache *AssetCache) *ServerSource

NewServerSource creates a new server asset source

func ReadServerSource

func ReadServerSource(authToken string, httpClient *utils.HTTPClient, cache *AssetCache, data json.RawMessage) (*ServerSource, error)

ReadServerSource reads a server asset source fronm the given JSON

func (*ServerSource) Channels

func (s *ServerSource) Channels() ([]assets.Channel, error)

Channels returns all channel assets

func (*ServerSource) Fields

func (s *ServerSource) Fields() ([]assets.Field, error)

Fields returns all field assets

func (*ServerSource) Flow

func (s *ServerSource) Flow(uuid assets.FlowUUID) (assets.Flow, error)

Flow returns the flow asset with the given UUID

func (*ServerSource) Groups

func (s *ServerSource) Groups() ([]assets.Group, error)

Groups returns all group assets

func (*ServerSource) Labels

func (s *ServerSource) Labels() ([]assets.Label, error)

Labels returns all label assets

func (*ServerSource) Locations

func (s *ServerSource) Locations() ([]assets.LocationHierarchy, error)

Locations returns all location assets

func (*ServerSource) Resthooks

func (s *ServerSource) Resthooks() ([]assets.Resthook, error)

Resthooks returns all resthook assets

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL