server

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeErrorResponse

func EncodeErrorResponse(err error, w http.ResponseWriter) error

EncodeErrorResponse writes the error response for any error that occurred during the request

func EncodeJSONResponse

func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error

EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code

func Logger

func Logger(inner http.Handler) http.Handler

func NewRouter

func NewRouter(c *Controller) *mux.Router

NewRouter creates a new router for any number of api routers

Types

type ApiError

type ApiError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type ApiService

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

ApiService is a service that implents the logic for the ApiServicer This service should implement the business logic for every endpoint for the API. Include any external packages or services that will be required by this service.

func (*ApiService) DeleteAsset

func (s *ApiService) DeleteAsset(assetId string) (interface{}, error)

DeleteAsset -

func (*ApiService) GetAsset

func (s *ApiService) GetAsset(assetId string) (interface{}, error)

GetAsset -

func (*ApiService) GetAssets

func (s *ApiService) GetAssets() (interface{}, error)

GetAssets -

func (*ApiService) GetJob

func (s *ApiService) GetJob(jobId string) (interface{}, error)

GetJob -

func (*ApiService) PostAsset

func (s *ApiService) PostAsset(assetCreate AssetCreate) (interface{}, error)

PostAsset -

func (*ApiService) PostJob

func (s *ApiService) PostJob(jobCreate JobCreate) (interface{}, error)

PostJob -

func (*ApiService) PutAsset

func (s *ApiService) PutAsset(assetId string, assetUpdate AssetUpdate) (interface{}, error)

PutAsset -

type ApiServicer

type ApiServicer interface {
	GetAssets() (interface{}, error)
	PostAsset(AssetCreate) (interface{}, error)
	GetAsset(string) (interface{}, error)
	PutAsset(string, AssetUpdate) (interface{}, error)
	DeleteAsset(string) (interface{}, error)
	GetJob(string) (interface{}, error)
	PostJob(JobCreate) (interface{}, error)
}

ApiServicer defines the api actions for the API

func NewApiService

func NewApiService() ApiServicer

NewApiService creates an api service

type AssetCreate

type AssetCreate struct {
	URL     string `json:"url"`
	AssetID string `json:"asset_id"`
}

type AssetUpdate

type AssetUpdate struct {
	Kind string `json:"kind,omitempty"`

	File opendam.File `json:"file,omitempty"`

	// additional assets/files associated with the asset
	Formats []opendam.Asset `json:"formats,omitempty"`

	// A list of metadata tags associated with the asset
	Tags []string `json:"tags,omitempty"`

	// Any user supplied metadata for the asset
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

AssetUpdate - A limited view of an asset with only editable fields. Formats, tags, and metadata are merged with any existing values

type Controller

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

A Controller binds http requests to an api service and writes the service results to the http response

func NewController

func NewController(s ApiServicer) *Controller

NewController creates an api controller

func (*Controller) DeleteAsset

func (c *Controller) DeleteAsset(w http.ResponseWriter, r *http.Request)

DeleteAsset -

func (*Controller) GetAsset

func (c *Controller) GetAsset(w http.ResponseWriter, r *http.Request)

GetAsset -

func (*Controller) GetAssets

func (c *Controller) GetAssets(w http.ResponseWriter, r *http.Request)

GetAssets -

func (*Controller) GetJob

func (c *Controller) GetJob(w http.ResponseWriter, r *http.Request)

GetJob -

func (*Controller) PostAsset

func (c *Controller) PostAsset(w http.ResponseWriter, r *http.Request)

PostAsset -

func (*Controller) PostJob

func (c *Controller) PostJob(w http.ResponseWriter, r *http.Request)

PostJob -

func (*Controller) PutAsset

func (c *Controller) PutAsset(w http.ResponseWriter, r *http.Request)

PutAsset -

type JobCreate

type JobCreate struct {
	Tasks []Task `json:"tasks"`
}

type Task

type Task struct {
	Name string   `json:"name"`
	Args []string `json:"args"`
}

Jump to

Keyboard shortcuts

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