endpoints

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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) endpoint.Middleware

LoggingMiddleware returns an endpoint middleware that logs the duration of each invocation, and the resulting error, if any.

func MakeAddEndpoint

func MakeAddEndpoint(svc service.TodoService) (ep endpoint.Endpoint)

MakeAddEndpoint returns an endpoint that invokes Add on the service. Primarily useful in a server.

func MakeDeleteEndpoint

func MakeDeleteEndpoint(svc service.TodoService) (ep endpoint.Endpoint)

MakeDeleteEndpoint returns an endpoint that invokes Delete on the service. Primarily useful in a server.

func MakeListEndpoint

func MakeListEndpoint(svc service.TodoService) (ep endpoint.Endpoint)

MakeListEndpoint returns an endpoint that invokes List on the service. Primarily useful in a server.

func MakeUpdateEndpoint

func MakeUpdateEndpoint(svc service.TodoService) (ep endpoint.Endpoint)

MakeUpdateEndpoint returns an endpoint that invokes Update on the service. Primarily useful in a server.

Types

type AddRequest

type AddRequest struct {
	Todo *model.TodoReq `json:"todo"`
}

AddRequest collects the request parameters for the Add method.

type AddResponse

type AddResponse struct {
	Res *model.TodoRes `json:"res"`
	Err error          `json:"-"`
}

AddResponse collects the response values for the Add method.

func (AddResponse) Headers

func (r AddResponse) Headers() http.Header

func (AddResponse) Response

func (r AddResponse) Response() interface{}

func (AddResponse) StatusCode

func (r AddResponse) StatusCode() int

type CompleteAllResponse

type CompleteAllResponse struct {
	Err error `json:"-"`
}

CompleteAllResponse collects the response values for the CompleteAll method.

type DeleteRequest

type DeleteRequest struct {
	Id string `json:"id"`
}

DeleteRequest collects the request parameters for the Delete method.

type DeleteResponse

type DeleteResponse struct {
	Err error `json:"-"`
}

DeleteResponse collects the response values for the Delete method.

func (DeleteResponse) Headers

func (r DeleteResponse) Headers() http.Header

func (DeleteResponse) Response

func (r DeleteResponse) Response() interface{}

func (DeleteResponse) StatusCode

func (r DeleteResponse) StatusCode() int

type Endpoints

type Endpoints struct {
	AddEndpoint    endpoint.Endpoint `json:""`
	DeleteEndpoint endpoint.Endpoint `json:""`
	UpdateEndpoint endpoint.Endpoint `json:""`
	ListEndpoint   endpoint.Endpoint `json:""`
}

Endpoints collects all of the endpoints that compose the todo service. It's meant to be used as a helper struct, to collect all of the endpoints into a single parameter.

func AuthnMiddleware

func AuthnMiddleware(n endpoint.Middleware, endpoints Endpoints) Endpoints

AuthnMiddleware returns an endpoint middleware that apply authentication func

func AuthzMiddleware

func AuthzMiddleware(z func(action string, resource string) endpoint.Middleware, endpoints Endpoints) Endpoints

AuthzMiddleware returns an endpoint middleware that apply authorization func (opa rbac)

func New

func New(svc service.TodoService, logger log.Logger, otTracer stdopentracing.Tracer, zipkinTracer *stdzipkin.Tracer) (ep Endpoints)

New return a new instance of the endpoint that wraps the provided service.

func (Endpoints) Add

func (e Endpoints) Add(ctx context.Context, todo *model.TodoReq) (res *model.TodoRes, err error)

Add implements the service interface, so Endpoints may be used as a service. This is primarily useful in the context of a client library.

func (Endpoints) Delete

func (e Endpoints) Delete(ctx context.Context, id string) (err error)

Delete implements the service interface, so Endpoints may be used as a service. This is primarily useful in the context of a client library.

func (Endpoints) List

func (e Endpoints) List(ctx context.Context) (res []*model.TodoRes, err error)

List implements the service interface, so Endpoints may be used as a service. This is primarily useful in the context of a client library.

func (Endpoints) Update

func (e Endpoints) Update(ctx context.Context, id string, todo *model.TodoReq) (res *model.TodoRes, err error)

Update implements the service interface, so Endpoints may be used as a service. This is primarily useful in the context of a client library.

type ListRequest

type ListRequest struct {
}

ListRequest collects the request parameters for the List method.

type ListResponse

type ListResponse struct {
	Res []*model.TodoRes `json:"res"`
	Err error            `json:"-"`
}

ListResponse collects the response values for the List method.

func (ListResponse) Headers

func (r ListResponse) Headers() http.Header

func (ListResponse) Response

func (r ListResponse) Response() interface{}

func (ListResponse) StatusCode

func (r ListResponse) StatusCode() int

type Request

type Request interface {
	// contains filtered or unexported methods
}

type UpdateRequest

type UpdateRequest struct {
	Id   string         `json:"id"`
	Todo *model.TodoReq `json:"todo"`
}

UpdateRequest collects the request parameters for the Update method.

type UpdateResponse

type UpdateResponse struct {
	Res *model.TodoRes `json:"res"`
	Err error          `json:"-"`
}

UpdateResponse collects the response values for the Update method.

func (UpdateResponse) Headers

func (r UpdateResponse) Headers() http.Header

func (UpdateResponse) Response

func (r UpdateResponse) Response() interface{}

func (UpdateResponse) StatusCode

func (r UpdateResponse) StatusCode() int

Jump to

Keyboard shortcuts

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