handlers

package
v2.15.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2017 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package handlers of Tideland GoREST implements some initial resource handlers to integrate into own solutions.

Index

Constants

View Source
const (
	ErrUploadingFile = iota + 1
	ErrDownloadingFile
)

Error codes of the handlers package.

Variables

This section is empty.

Functions

func NewAuditHandler

func NewAuditHandler(id string, assert audit.Assertion, ahf AuditHandlerFunc) rest.ResourceHandler

NewAuditHandler creates a handler able to handle all types of requests with the passed AuditHandlerFunc. Here the tests can be done.

func NewFileServeHandler

func NewFileServeHandler(id, dir string) rest.ResourceHandler

NewFileServeHandler creates a new handler serving the files names by the resource ID part out of the passed directory.

func NewFileUploadHandler

func NewFileUploadHandler(id string, processor FileUploadProcessor) rest.ResourceHandler

NewFileUploadHandler creates a new handler for the uploading of files.

func NewJWTAuthorizationHandler

func NewJWTAuthorizationHandler(id string, config *JWTAuthorizationConfig) rest.ResourceHandler

NewJWTAuthorizationHandler creates a handler checking for a valid JSON Web Token in each request.

func NewWrapperHandler

func NewWrapperHandler(id string, hf http.HandlerFunc) rest.ResourceHandler

NewWrapperHandler creates a new wrapper around a standard handler function.

Types

type AuditHandlerFunc

type AuditHandlerFunc func(assert audit.Assertion, job rest.Job) (bool, error)

AuditHandlerFunc defines the function which will be executed for each request. The assert can be used for tests.

type FileUploadProcessor

type FileUploadProcessor func(job rest.Job, header *multipart.FileHeader, file multipart.File) error

FileUploadProcessor defines the function used for the processing of the uploaded file. It has to be specified by the user of the handler and e.g. persists the received data in the file system or a database.

type JWTAuthorizationConfig

type JWTAuthorizationConfig struct {
	Cache      jwt.Cache
	Key        jwt.Key
	Leeway     time.Duration
	Gatekeeper func(job rest.Job, claims jwt.Claims) error
	Logger     func(job rest.Job, msg string)
}

JWTAuthorizationConfig allows to control how the JWT authorization handler works. All values are optional. In this case tokens are only decoded without using a cache, validated for the current time plus/minus a minute leeway, and there's no user defined gatekeeper function running afterwards. In case of a denial a warning is written with the standard logger.

Jump to

Keyboard shortcuts

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