unitsvc

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2017 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubjCreateUnit = "units.create"
	SubjRenameUnit = "units.rename"
	SubjDeleteUnit = "units.delete"
)

Variables

View Source
var (
	ErrBadRequest = errors.New("request is malformed or invalid")
)
View Source
var (
	ErrNotFound = errors.New("the requested resource could not be found, or the user is not allowed to view it")
)

Functions

func DecodeCreateUnitRequest

func DecodeCreateUnitRequest(_ context.Context, r *http.Request) (interface{}, error)

func DecodeCreateUnitResponse

func DecodeCreateUnitResponse(_ context.Context, resp *http.Response) (interface{}, error)

func DecodeDeleteUnitRequest

func DecodeDeleteUnitRequest(_ context.Context, r *http.Request) (interface{}, error)

func DecodeDeleteUnitResponse

func DecodeDeleteUnitResponse(_ context.Context, resp *http.Response) (interface{}, error)

func DecodeGetUnitRequest

func DecodeGetUnitRequest(_ context.Context, r *http.Request) (interface{}, error)

func DecodeGetUnitResponse

func DecodeGetUnitResponse(_ context.Context, resp *http.Response) (interface{}, error)

func DecodeListUnitsRequest

func DecodeListUnitsRequest(_ context.Context, r *http.Request) (interface{}, error)

func DecodeListUnitsResponse

func DecodeListUnitsResponse(_ context.Context, resp *http.Response) (interface{}, error)

func DecodeRenameUnitRequest

func DecodeRenameUnitRequest(_ context.Context, r *http.Request) (interface{}, error)

func DecodeRenameUnitResponse

func DecodeRenameUnitResponse(_ context.Context, resp *http.Response) (interface{}, error)

func EncodeCreateUnitRequest

func EncodeCreateUnitRequest(ctx context.Context, req *http.Request, request interface{}) error

func EncodeDeleteUnitRequest

func EncodeDeleteUnitRequest(ctx context.Context, req *http.Request, request interface{}) error

func EncodeGetUnitRequest

func EncodeGetUnitRequest(ctx context.Context, req *http.Request, request interface{}) error

func EncodeListUnitsRequest

func EncodeListUnitsRequest(ctx context.Context, req *http.Request, request interface{}) error

func EncodeRenameUnitRequest

func EncodeRenameUnitRequest(ctx context.Context, req *http.Request, request interface{}) error

func MakeCreateUnitEndpoint

func MakeCreateUnitEndpoint(s Service) endpoint.Endpoint

func MakeDeleteUnitEndpoint

func MakeDeleteUnitEndpoint(s Service) endpoint.Endpoint

func MakeGetUnitEndpoint

func MakeGetUnitEndpoint(s Service) endpoint.Endpoint

func MakeHTTPHandler

func MakeHTTPHandler(s Service, logger log.Logger, ti oauth2.Introspector) http.Handler

func MakeListUnitsEndpoint

func MakeListUnitsEndpoint(s Service) endpoint.Endpoint

func MakeRenameUnitEndpoint

func MakeRenameUnitEndpoint(s Service) endpoint.Endpoint

Types

type Endpoints

type Endpoints struct {
	ListUnitsEndpoint  endpoint.Endpoint
	GetUnitEndpoint    endpoint.Endpoint
	CreateUnitEndpoint endpoint.Endpoint
	RenameUnitEndpoint endpoint.Endpoint
	DeleteUnitEndpoint endpoint.Endpoint
}

func MakeClientEndpoints

func MakeClientEndpoints(instance string) (Endpoints, error)

func MakeServerEndpoints

func MakeServerEndpoints(s Service) Endpoints

func (Endpoints) CreateUnit

func (e Endpoints) CreateUnit(ctx context.Context, classID uuid.UUID, title string) error

func (Endpoints) DeleteUnit

func (e Endpoints) DeleteUnit(ctx context.Context, unitID uuid.UUID) error

func (Endpoints) GetUnit

func (e Endpoints) GetUnit(ctx context.Context, unitID uuid.UUID) (*models.Unit, error)

func (Endpoints) ListUnits

func (e Endpoints) ListUnits(ctx context.Context, classID uuid.UUID) ([]uuid.UUID, error)

func (Endpoints) RenameUnit

func (e Endpoints) RenameUnit(ctx context.Context, unitID uuid.UUID, title string) error

type Middleware

type Middleware func(Service) Service

func InstrumentingMiddleware

func InstrumentingMiddleware(
	requestCount metrics.Counter,
	requestLatency metrics.Histogram,
) Middleware

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) Middleware

func MessagingMiddleware

func MessagingMiddleware(nc *nats.Conn) Middleware

type Service

type Service interface {
	ListUnits(ctx context.Context, classID uuid.UUID) ([]uuid.UUID, error)
	GetUnit(ctx context.Context, unitID uuid.UUID) (*models.Unit, error)
	CreateUnit(ctx context.Context, classID uuid.UUID, title string) error
	RenameUnit(ctx context.Context, unitID uuid.UUID, title string) error
	DeleteUnit(ctx context.Context, unitID uuid.UUID) error
}

func New

func New(db *sql.DB, cs classsvc.Service) Service

Jump to

Keyboard shortcuts

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