handler

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDisabledDeliveryKind defines an error caused by a disabled delivery kind.
	// TODO: move to receiver handler, or use invalid resource
	ErrDisabledDeliveryKind = errors.New("disabled delivery kind")

	// ErrDisabledMessageKind defines an error caused by a disabled message kind.
	// TODO: move to receiver handler, or use invalid resource
	ErrDisabledMessageKind = errors.New("disabled message kind")
)

Functions

func HandleRequest

func HandleRequest(requestHandler RequestHandler, na action.NamespaceActioner) http.Handler

HandleRequest receives the request and splits it into usable data that are agnostic of HTTP. It will also handle the response, based on the handler's result.

func PathScope

func PathScope(ctx context.Context) *resource.Namespace

func SetPathScope

func SetPathScope(ctx context.Context, scope *resource.Namespace) context.Context

Types

type DeliveryKindHandler

type DeliveryKindHandler struct {
	// contains filtered or unexported fields
}

DeliveryKindHandler defines an HTTP server handler for delivery kind endpoints.

func NewDeliveryKindHandler

func NewDeliveryKindHandler(
	dka action.DeliveryKindActioner,
	authz authorizer.Authorizer,
) *DeliveryKindHandler

NewDeliveryKindHandler creates a new delivery kind handler.

func (*DeliveryKindHandler) Delete

func (h *DeliveryKindHandler) Delete(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Delete handles a request to delete an existing namespace, specified by its ID.

func (*DeliveryKindHandler) GetByID

func (h *DeliveryKindHandler) GetByID(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

GetByID handles a request to retrieve an existing delivery kind, specified by its ID.

func (*DeliveryKindHandler) GetMany

func (h *DeliveryKindHandler) GetMany(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

GetMany handles a request to retrieve multiple delivery kinds. The params can contain OData values to filter, sort, and paginate the results.

func (*DeliveryKindHandler) Patch

func (h *DeliveryKindHandler) Patch(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Patch handles a request to update an existing delivery kind, specified by its ID, by only providing its changed attributes.

func (*DeliveryKindHandler) Post

func (h *DeliveryKindHandler) Post(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Post handles a request to create a new delivery kind.

func (*DeliveryKindHandler) Put

func (h *DeliveryKindHandler) Put(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Put handles a request to update an existing delivery kind, specified by its ID, by providing all of its attributes.

type DeliveryResponse

type DeliveryResponse struct {
	DeliveryKind  string     `json:"deliveryKind"`
	LanguageTag   string     `json:"languageTag"`
	Status        string     `json:"status"`
	StatusMessage string     `json:"statusMessage,omitempty"`
	DeliverTime   *time.Time `json:"deliverTime"`
}

DeliveryResponse defines the body of a response related to a delivery resource.

type MessageHandler

type MessageHandler struct {
	// contains filtered or unexported fields
}

MessageHandler defines an HTTP server handler for message endpoints.

func NewMessageHandler

New creates a new message handler.

func (*MessageHandler) GetByID

func (h *MessageHandler) GetByID(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

func (*MessageHandler) GetMany

func (h *MessageHandler) GetMany(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

func (*MessageHandler) Post

func (h *MessageHandler) Post(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Post handles the creation of a new message and a delivery, and pushes this delivery into the message queue to be delivered by the Deliverer service.

type MessageKindHandler

type MessageKindHandler struct {
	// contains filtered or unexported fields
}

MessageKindHandler defines an HTTP server handler for message kind endpoints.

func NewMessageKindHandler

func NewMessageKindHandler(
	mka action.MessageKindActioner,
	authz authorizer.Authorizer,
) *MessageKindHandler

New creates a new message kind handler.

func (*MessageKindHandler) Delete

func (h *MessageKindHandler) Delete(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Delete handles the deletion of a message kind, specified by its ID or code.

func (*MessageKindHandler) GetByID

func (h *MessageKindHandler) GetByID(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

func (*MessageKindHandler) GetMany

func (h *MessageKindHandler) GetMany(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

func (*MessageKindHandler) Patch

func (h *MessageKindHandler) Patch(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Patch handles the modification of an existing message kind, specified by its ID, by providing only its changed attributes.

func (*MessageKindHandler) Post

func (h *MessageKindHandler) Post(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Post handles the creation of a new message kind.

func (*MessageKindHandler) Put

func (h *MessageKindHandler) Put(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Put handles the update of an existing message kind, specified by its ID or code, by providing all of its attributes.

type MessageRequest

type MessageRequest struct {
	MessageKind  string                 `json:"messageKind"`
	DeliveryKind string                 `json:"deliveryKind"`
	LanguageTag  string                 `json:"languageTag"`
	Input        map[string]interface{} `json:"input"`
	ScheduleTime *time.Time             `json:"scheduleTime"`
}

MessageRequest defines the body of a request related to a message resource.

type MessageResponse

type MessageResponse struct {
	ID           uuid.UUID              `json:"id"`
	MessageKind  string                 `json:"messageKind"`
	Input        map[string]interface{} `json:"input"`
	Status       string                 `json:"status"`
	ScheduleTime *time.Time             `json:"scheduleTime,omitempty"`
	CreateTime   time.Time              `json:"createTime"`
	Deliveries   []*DeliveryResponse    `json:"deliveries"`
}

MessageResponse defines the body of a response related to a message resource.

type NamespaceHandler

type NamespaceHandler struct {
	// contains filtered or unexported fields
}

NamespaceHandler defines an HTTP server handler for namespace endpoints.

func NewNamespaceHandler

func NewNamespaceHandler(
	na action.NamespaceActioner,
	authz authorizer.Authorizer,
) *NamespaceHandler

New creates a new namespace handler.

func (*NamespaceHandler) Delete

func (h *NamespaceHandler) Delete(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Delete handles a request to delete an existing namespace, specified by its ID.

func (*NamespaceHandler) GetByID

func (h *NamespaceHandler) GetByID(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

GetByID handles a request to retrieve an existing namespace, specified by its ID.

func (*NamespaceHandler) GetMany

func (h *NamespaceHandler) GetMany(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

GetMany handles a request to retrieve multiple namespaces. The params can contain OData values to filter, sort, and paginate the results.

func (*NamespaceHandler) Patch

func (h *NamespaceHandler) Patch(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Patch handles a request to update an existing namespace, specified by its ID, by only providing its changed attributes.

func (*NamespaceHandler) Post

func (h *NamespaceHandler) Post(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Post handles a request to create a new namespace.

func (*NamespaceHandler) Put

func (h *NamespaceHandler) Put(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Put handles a request to update an existing namespace, specified by its ID, by providing all of its attributes.

type RequestHandler

type RequestHandler func(context.Context, map[string]string, io.Reader) (interface{}, map[string]interface{}, error)

type TemplateHandler

type TemplateHandler struct {
	// contains filtered or unexported fields
}

TemplateHandler defines an HTTP server handler for template endpoints.

func NewTemplateHandler

NewTemplateHandler creates a new template handler.

func (*TemplateHandler) Delete

func (h *TemplateHandler) Delete(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Delete handles the deletion of a template, specified by its ID.

func (*TemplateHandler) GetByID

func (h *TemplateHandler) GetByID(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

func (*TemplateHandler) GetMany

func (h *TemplateHandler) GetMany(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

func (*TemplateHandler) Patch

func (h *TemplateHandler) Patch(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Patch handles the modification of an existing template, specified by its ID, by providing only its changed attributes.

func (*TemplateHandler) Post

func (h *TemplateHandler) Post(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Post handles the creation of a new template.

func (*TemplateHandler) Put

func (h *TemplateHandler) Put(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Put handles the update of an existing template, specified by its ID, by providing all of its attributes.

type TemplateKindHandler

type TemplateKindHandler struct {
	// contains filtered or unexported fields
}

TemplateKindHandler defines an HTTP server handler for template kind endpoints.

func NewTemplateKindHandler

NewTemplateKindHandler creates a new template kind handler.

func (*TemplateKindHandler) Delete

func (h *TemplateKindHandler) Delete(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Delete handles the deletion of a template kind, specified by its ID or code.

func (*TemplateKindHandler) GetByID

func (h *TemplateKindHandler) GetByID(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

func (*TemplateKindHandler) GetMany

func (h *TemplateKindHandler) GetMany(
	ctx context.Context,
	params map[string]string,
	_ io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

func (*TemplateKindHandler) Patch

func (h *TemplateKindHandler) Patch(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Patch handles the modification of an existing template kind, specified by its ID, by providing only its changed attributes.

func (*TemplateKindHandler) Post

func (h *TemplateKindHandler) Post(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Post handles the creation of a new template kind.

func (*TemplateKindHandler) Put

func (h *TemplateKindHandler) Put(
	ctx context.Context,
	params map[string]string,
	body io.Reader,
) (data interface{}, meta map[string]interface{}, err error)

Put handles the update of an existing template kind, specified by its ID or code, by providing all of its attributes.

Jump to

Keyboard shortcuts

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