Documentation ¶
Index ¶
- func JsonError(w http.ResponseWriter, err error)
- func NewHandler(crud Frontend) http.Handler
- func Next(filters []Filter, outerOp OuterOperation, innerOp InnerOperation, ...) string
- func Prev(filters []Filter, outerOp OuterOperation, innerOp InnerOperation, ...) string
- type Error
- type Filter
- type Frontend
- type InnerOperation
- type MediaFrontend
- type Operator
- type OuterOperation
- type Resource
- type ResourceFrontend
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JsonError ¶
func JsonError(w http.ResponseWriter, err error)
JsonError writes an error to the response
func NewHandler ¶
func Next ¶
func Next(filters []Filter, outerOp OuterOperation, innerOp InnerOperation, sort []string, ascending bool, offset, limit int) string
Next build Next URL for filtering
func Prev ¶
func Prev(filters []Filter, outerOp OuterOperation, innerOp InnerOperation, sort []string, ascending bool, offset, limit int) string
Next build Next URL for filtering
Types ¶
type Error ¶
type Error int
Static error type
const ( NoError Error = iota ErrInvalidFilter ErrInvalidColumn ErrInvalidOperator ErrNotFound ErrEmptyBody ErrInvalidJson ErrMissingResourceId ErrUnsupportedMethod ErrMultipartName ErrMultipartNeedsContentType ErrMultipartTooManyFiles ErrMultipartNoFile ErrMimeNotSupported ErrUnsupportedMediaType ErrorMisingAuthHeader ErrorInvalidAuthHeader ErrorUnexpectedSigningMethod ErrorInvalidToken ErrorInvalidRole ErrorMissingRole )
type Frontend ¶
type Frontend interface { Get(r *http.Request) (io.ReadCloser, error) Post(r *http.Request) (io.ReadCloser, error) Put(r *http.Request) error Delete(r *http.Request) error }
Frontend implements a CRUD frontend service
type InnerOperation ¶
type InnerOperation string
const ( INNER_AND InnerOperation = "AND" INNER_OR InnerOperation = "OR" INNER_DEFAULT InnerOperation = INNER_AND )
Operations to merge several values within a single filter
type MediaFrontend ¶
type MediaFrontend struct {
// contains filtered or unexported fields
}
func FromMedia ¶
func FromMedia(r Resource, unpoliced Resource, tmpFolder, finalFolder string, mimeTypes map[string]string, ffmpegPath string) MediaFrontend
FromMedia creates a new MediaFrontend
func (MediaFrontend) Get ¶
func (h MediaFrontend) Get(r *http.Request) (io.ReadCloser, error)
Get handler
func (MediaFrontend) MediaFolder ¶
func (h MediaFrontend) MediaFolder() string
MediaFolder returns the root media folder
func (MediaFrontend) Post ¶
func (h MediaFrontend) Post(r *http.Request) (io.ReadCloser, error)
Post handler
type OuterOperation ¶
type OuterOperation string
const ( OUTER_AND OuterOperation = "AND" OUTER_OR OuterOperation = "OR" OUTER_DEFAULT OuterOperation = OUTER_AND )
Operations to merge several separate filters
type Resource ¶
type Resource interface { // Get resource by id GetById(context.Context, string) (io.ReadCloser, error) // Get resource by filter Get(ctx context.Context, filter []Filter, outerOp OuterOperation, innerOp InnerOperation, sort []string, ascending bool, offset, limit int, count bool) (io.ReadCloser, error) // Post (create) new resource Post(context.Context, io.Reader) (io.ReadCloser, error) // Put (update) resource Put(context.Context, string, io.Reader) error // Delete resource by id Delete(context.Context, string) error }
Resource implements the CRUD operations
type ResourceFrontend ¶
type ResourceFrontend struct {
// contains filtered or unexported fields
}
ResourceFrontend implements Frontend
func FromResource ¶
func FromResource(r Resource) ResourceFrontend
NewResourceHandler for a given kind of Resource
func (ResourceFrontend) Delete ¶
func (h ResourceFrontend) Delete(r *http.Request) error
Delete handler
func (ResourceFrontend) Get ¶
func (h ResourceFrontend) Get(r *http.Request) (io.ReadCloser, error)
func (ResourceFrontend) Post ¶
func (h ResourceFrontend) Post(r *http.Request) (io.ReadCloser, error)
Post handler
Click to show internal directories.
Click to hide internal directories.