service

package
v0.0.0-...-dd0ccd7 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ALL      = "all"
	ACTIVE   = "active"
	COMPLETE = "complete"
)

Variables

View Source
var (
	ErrMalformedEntity = errors.New("malformed entity specification")

	ErrNotFound = errors.New("non-existent entity")

	ErrInvalidQueryParams = errors.New("invalid query params")
)
View Source
var (
	// Version will be assigned with go build
	Version = ""
	// CommitHash will be assigned with go build
	CommitHash = ""
	// BuildTimeStamp will be assigned with go build
	BuildTimeStamp = ""
)

Functions

This section is empty.

Types

type Middleware

type Middleware func(TodoService) TodoService

Middleware describes a service (as opposed to endpoint) middleware.

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) Middleware

LoggingMiddleware takes a logger as a dependency and returns a ServiceMiddleware.

type TodoService

type TodoService interface {
	// [method=post,expose=true,router=items]
	Add(ctx context.Context, todo *model.TodoReq) (res *model.TodoRes, err error)
	// [method=delete,expose=true,router=items/:id]
	Delete(ctx context.Context, id string) (err error)
	// [method=put,expose=true,router=items/:id]
	Update(ctx context.Context, id string, todo *model.TodoReq) (res *model.TodoRes, err error)
	// [method=get,expose=true,router=items]
	List(ctx context.Context) (res []*model.TodoRes, err error)
}

Service describes a service that adds things together Implement yor service methods methods. e.x: Foo(ctx context.Context, s string)(rs string, err error)

func New

func New(repo model.TodoRepository, logger log.Logger) (s TodoService)

New return a new instance of the service. If you want to add service middleware this is the place to put them.

Jump to

Keyboard shortcuts

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