Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSON

func JSON(c echo.Context, status int, i interface{}) error

JSON response.

func NewHandler

func NewHandler(s *Server) http.Handler

NewHandler returns http.Handler for Server.

Types

type Fire

type Fire interface {
	dstore.Documents
	events.Events
}

Fire defines interface for remote store (like Firestore).

type LogLevel

type LogLevel int

LogLevel ...

const (
	// DebugLevel ...
	DebugLevel LogLevel = 3
	// InfoLevel ...
	InfoLevel LogLevel = 2
	// WarnLevel ...
	WarnLevel LogLevel = 1
	// ErrLevel ...
	ErrLevel LogLevel = 0
	// NoLevel ...
	NoLevel LogLevel = -1
)

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Errorf(format string, args ...interface{})
}

Logger compatible with GCP.

func NewLogger

func NewLogger(lev LogLevel) Logger

NewLogger ...

type Redis

type Redis interface {
	// Get returns value at key.
	Get(ctx context.Context, k string) (string, error)
	// Put puts a value at key.
	Set(ctx context.Context, k string, v string) error
	// Delete key.
	Delete(ctx context.Context, k string) error
	// Expire key.
	Expire(ctx context.Context, k string, dt time.Duration) error
	// Increment value at key.
	Increment(ctx context.Context, k string) (int64, error)
	// Publish data to key.
	Publish(ctx context.Context, k string, b []byte) error
}

Redis defines interface for a distributed key value store. Used to prevent nonce re-use for authenticated requests.

func NewRedisTest

func NewRedisTest(clock tsutil.Clock) Redis

NewRedisTest returns Redis for testing.

type Server

type Server struct {

	// URL (base) of form http(s)://host:port with no trailing slash to help
	// authorization checks in testing where the host is ambiguous.
	URL string

	// contains filtered or unexported fields

}

Server ...

func New

func New(fi Fire, rds Redis, client http.Client, clock tsutil.Clock, logger Logger) *Server

New creates a Server.

func (*Server) AddRoutes

func (s *Server) AddRoutes(e *echo.Echo)

AddRoutes adds routes to an Echo instance.

func (*Server) ErrBadRequest

func (s *Server) ErrBadRequest(c echo.Context, err error) error

ErrBadRequest response.

func (*Server) ErrConflict

func (s *Server) ErrConflict(c echo.Context, err error) error

ErrConflict response.

func (*Server) ErrEntityTooLarge

func (s *Server) ErrEntityTooLarge(c echo.Context, err error) error

ErrEntityTooLarge response.

func (*Server) ErrForbidden

func (s *Server) ErrForbidden(c echo.Context, err error) error

ErrForbidden response.

func (*Server) ErrInternalServer

func (s *Server) ErrInternalServer(c echo.Context, err error) error

ErrInternalServer response.

func (*Server) ErrNotFound

func (s *Server) ErrNotFound(c echo.Context, err error) error

ErrNotFound response.

func (*Server) ErrResponse

func (s *Server) ErrResponse(c echo.Context, status int, err error) error

ErrResponse is a generate error response.

func (*Server) ErrorHandler

func (s *Server) ErrorHandler(err error, c echo.Context)

ErrorHandler returns error handler that returns in the format: {"error": {"message": "error message", status: 500}}".

func (*Server) SetAdmins

func (s *Server) SetAdmins(admins []keys.ID)

SetAdmins sets authorized admins.

func (*Server) SetClock

func (s *Server) SetClock(clock tsutil.Clock)

SetClock sets clock.

func (*Server) SetInternalAuth

func (s *Server) SetInternalAuth(internalAuth string)

SetInternalAuth for authorizing internal requests, like tasks.

func (*Server) SetInternalKey

func (s *Server) SetInternalKey(internalKey string) error

SetInternalKey for encrypting between internal services.

func (*Server) SetTasks

func (s *Server) SetTasks(tasks Tasks)

SetTasks ...

type TaskPriority

type TaskPriority int

TaskPriority suggests a higher priority queue.

const (
	// HighPriority ...
	HighPriority TaskPriority = 1
	// LowPriority ...
	LowPriority TaskPriority = 100
)

type Tasks

type Tasks interface {
	// CreateTask ...
	CreateTask(ctx context.Context, method string, url string, authToken string, priority TaskPriority) error
}

Tasks ..

func NewTestTasks

func NewTestTasks(svr *Server) Tasks

NewTestTasks returns Tasks for use in tests.