http

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunServer

func RunServer(ctx context.Context, cfg *domain.Config, router *gin.Engine)

RunServer runs an HTTP server based on config and router.

func SetupRouter

func SetupRouter(logger *slog.Logger, queueHandler *QueueHandler, messageHandler *MessageHandler, topicHandler *TopicHandler, subscriptionHandler *SubscriptionHandler, healthCheckHandler *HealthCheckHandler) *gin.Engine

Types

type HealthCheckHandler added in v0.3.0

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

HealthCheckHandler exposes a REST API for domain.HealthCheckService.

func NewHealthCheckHandler added in v0.3.0

func NewHealthCheckHandler(healthCheckService domain.HealthCheckService) *HealthCheckHandler

NewHealthCheckHandler returns a new HealthCheckHandler.

func (*HealthCheckHandler) Check added in v0.3.0

func (h *HealthCheckHandler) Check(c *gin.Context)

Execute a health check.

@Summary	Execute a health check
@Tags		health-check
@Accept		json
@Produce	json
@Success	200	{object}	healthCheckResponse
@Failure	500	{object}	errorResponse
@Router		/healthz [get]

type MessageHandler

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

Message exposes a REST API for domain.MessageService.

func NewMessageHandler

func NewMessageHandler(messageService domain.MessageService) *MessageHandler

NewMessageHandler returns a new MessageHandler.

func (*MessageHandler) Ack

func (m *MessageHandler) Ack(c *gin.Context)

Ack a message.

@Summary	Ack a message
@Tags		messages
@Accept		json
@Produce	json
@Param		queue_id	path	string	true	"Queue id"
@Param		message_id	path	string	true	"Message id"
@Success	204			"No Content"
@Failure	404			{object}	errorResponse
@Failure	500			{object}	errorResponse
@Router		/queues/{queue_id}/messages/{message_id}/ack [put]

func (*MessageHandler) Create

func (m *MessageHandler) Create(c *gin.Context)

Create a message.

@Summary	Add a message
@Tags		messages
@Accept		json
@Produce	json
@Param		queue_id	path	string			true	"Queue id"
@Param		request		body	messageRequest	true	"Add a message"
@Success	204			"No Content"
@Failure	400			{object}	errorResponse
@Failure	500			{object}	errorResponse
@Router		/queue/{queue_id}/messages [post]

func (*MessageHandler) List

func (m *MessageHandler) List(c *gin.Context)

List messages.

@Summary	List messages
@Tags		messages
@Accept		json
@Produce	json
@Param		queue_id	path		string	true	"Queue id"
@Param		label		path		string	false	"Filter by label"
@Param		limit		query		int		false	"The limit indicates the maximum number of items to return"
@Success	200			{object}	messageListResponse
@Failure	404			{object}	errorResponse
@Failure	500			{object}	errorResponse
@Router		/queues/{queue_id}/messages [get]

func (*MessageHandler) Nack

func (m *MessageHandler) Nack(c *gin.Context)

Nack a message.

@Summary	Nack a message
@Tags		messages
@Accept		json
@Produce	json
@Param		queue_id	path	string				true	"Queue id"
@Param		message_id	path	string				true	"Message id"
@Param		request		body	messageNackRequest	true	"Nack a message"
@Success	204			"No Content"
@Failure	404			{object}	errorResponse
@Failure	500			{object}	errorResponse
@Router		/queues/{queue_id}/messages/{message_id}/nack [put]

type QueueHandler

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

Queue exposes a REST API for domain.QueueService.

func NewQueueHandler

func NewQueueHandler(queueService domain.QueueService) *QueueHandler

NewQueueHandler returns a new QueueHandler.

func (*QueueHandler) Cleanup

func (q *QueueHandler) Cleanup(c *gin.Context)

Cleanup a queue.

@Summary	Cleanup a queue removing expired and acked messages
@Tags		queues
@Accept		json
@Produce	json
@Param		queue_id	path	string	true	"Queue id"
@Success	204			"No Content"
@Failure	404			{object}	errorResponse
@Failure	500			{object}	errorResponse
@Router		/queues/{queue_id}/cleanup [put]

func (*QueueHandler) Create

func (q *QueueHandler) Create(c *gin.Context)

Create a queue.

@Summary	Add a queue
@Tags		queues
@Accept		json
@Produce	json
@Param		request	body		queueRequest	true	"Add a queue"
@Success	201		{object}	queueResponse
@Failure	400		{object}	errorResponse
@Failure	500		{object}	errorResponse
@Router		/queues [post]

func (*QueueHandler) Delete

func (q *QueueHandler) Delete(c *gin.Context)

Delete a queue.

@Summary	Delete a queue
@Tags		queues
@Accept		json
@Produce	json
@Param		queue_id	path	string	true	"Queue id"
@Success	204			"No Content"
@Failure	404			{object}	errorResponse
@Failure	500			{object}	errorResponse
@Router		/queues/{queue_id} [delete]

func (*QueueHandler) Get

func (q *QueueHandler) Get(c *gin.Context)

Get a queue.

@Summary	Show a queue
@Tags		queues
@Accept		json
@Produce	json
@Param		queue_id	path		string	true	"Queue id"
@Success	200			{object}	queueResponse
@Failure	404			{object}	errorResponse
@Failure	500			{object}	errorResponse
@Router		/queues/{queue_id} [get]

func (*QueueHandler) List

func (q *QueueHandler) List(c *gin.Context)

List queues.

@Summary	List queues
@Tags		queues
@Accept		json
@Produce	json
@Param		limit	query		int	false	"The limit indicates the maximum number of items to return"
@Param		offset	query		int	false	"The offset indicates the starting position of the query in relation to the complete set of unpaginated items"
@Success	200		{object}	queueListResponse
@Failure	500		{object}	errorResponse
@Router		/queues [get]

func (*QueueHandler) Purge

func (q *QueueHandler) Purge(c *gin.Context)

Purge a queue.

@Summary	Purge a queue
@Tags		queues
@Accept		json
@Produce	json
@Param		queue_id	path	string	true	"Queue id"
@Success	204			"No Content"
@Failure	404			{object}	errorResponse
@Failure	500			{object}	errorResponse
@Router		/queues/{queue_id}/purge [put]

func (*QueueHandler) Stats

func (q *QueueHandler) Stats(c *gin.Context)

Get the queue stats.

@Summary	Get the queue stats
@Tags		queues
@Accept		json
@Produce	json
@Param		queue_id	path		string	true	"Queue id"
@Success	200			{object}	queueStatsResponse
@Failure	404			{object}	errorResponse
@Failure	500			{object}	errorResponse
@Router		/queues/{queue_id}/stats [get]

func (*QueueHandler) Update

func (q *QueueHandler) Update(c *gin.Context)

Update a queue.

@Summary	Update a queue
@Tags		queues
@Accept		json
@Produce	json
@Param		queue_id	path		string				true	"Queue id"
@Param		request		body		queueUpdateRequest	true	"Update a queue"
@Success	200			{object}	queueResponse
@Failure	400			{object}	errorResponse
@Failure	404			{object}	errorResponse
@Failure	500			{object}	errorResponse
@Router		/queues/{queue_id} [put]

type SubscriptionHandler added in v0.2.0

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

SubscriptionHandler exposes a REST API for domain.SubscriptionService.

func NewSubscriptionHandler added in v0.2.0

func NewSubscriptionHandler(subscriptionService domain.SubscriptionService) *SubscriptionHandler

NewSubscriptionHandler returns a new SubscriptionHandler.

func (*SubscriptionHandler) Create added in v0.2.0

func (s *SubscriptionHandler) Create(c *gin.Context)

Create a subscription.

@Summary	Add a subscription
@Tags		subscriptions
@Accept		json
@Produce	json
@Param		request	body		subscriptionRequest	true	"Add a subscription"
@Success	201		{object}	topicResponse
@Failure	400		{object}	errorResponse
@Failure	500		{object}	errorResponse
@Router		/subscriptions [post]

func (*SubscriptionHandler) Delete added in v0.2.0

func (s *SubscriptionHandler) Delete(c *gin.Context)

Delete a subscription.

@Summary	Delete a subscription
@Tags		subscriptions
@Accept		json
@Produce	json
@Param		subscription_id	path	string	true	"Subscription id"
@Success	204				"No Content"
@Failure	404				{object}	errorResponse
@Failure	500				{object}	errorResponse
@Router		/subscriptions/{subscription_id} [delete]

func (*SubscriptionHandler) Get added in v0.2.0

func (s *SubscriptionHandler) Get(c *gin.Context)

Get a subscription.

@Summary	Show a subscription
@Tags		subscriptions
@Accept		json
@Produce	json
@Param		subscription_id	path		string	true	"Subscription id"
@Success	200				{object}	subscriptionResponse
@Failure	404				{object}	errorResponse
@Failure	500				{object}	errorResponse
@Router		/subscriptions/{subscription_id} [get]

func (*SubscriptionHandler) List added in v0.2.0

func (s *SubscriptionHandler) List(c *gin.Context)

List subscriptions.

@Summary	List subscriptions
@Tags		subscriptions
@Accept		json
@Produce	json
@Param		limit	query		int	false	"The limit indicates the maximum number of items to return"
@Param		offset	query		int	false	"The offset indicates the starting position of the query in relation to the complete set of unpaginated items"
@Success	200		{object}	subscriptionListResponse
@Failure	500		{object}	errorResponse
@Router		/subscriptions [get]

type TopicHandler added in v0.2.0

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

Topic exposes a REST API for domain.TopicService.

func NewTopicHandler added in v0.2.0

func NewTopicHandler(topicService domain.TopicService) *TopicHandler

NewTopicHandler returns a new TopicHandler.

func (*TopicHandler) Create added in v0.2.0

func (t *TopicHandler) Create(c *gin.Context)

Create a topic.

@Summary	Add a topic
@Tags		topics
@Accept		json
@Produce	json
@Param		request	body		topicRequest	true	"Add a topic"
@Success	201		{object}	topicResponse
@Failure	400		{object}	errorResponse
@Failure	500		{object}	errorResponse
@Router		/topics [post]

func (*TopicHandler) CreateMessage added in v0.2.0

func (t *TopicHandler) CreateMessage(c *gin.Context)

Create a message.

@Summary	Add a message
@Tags		topics
@Accept		json
@Produce	json
@Param		request	body		messageRequest	true	"Add a message"
@Success	201		{object}	topicResponse
@Failure	400		{object}	errorResponse
@Failure	500		{object}	errorResponse
@Router		/topics/{topic_id}/messages [post]

func (*TopicHandler) Delete added in v0.2.0

func (t *TopicHandler) Delete(c *gin.Context)

Delete a topic.

@Summary	Delete a topic
@Tags		topics
@Accept		json
@Produce	json
@Param		topic_id	path	string	true	"Topic id"
@Success	204			"No Content"
@Failure	404			{object}	errorResponse
@Failure	500			{object}	errorResponse
@Router		/topics/{topic_id} [delete]

func (*TopicHandler) Get added in v0.2.0

func (t *TopicHandler) Get(c *gin.Context)

Get a topic.

@Summary	Show a topic
@Tags		topics
@Accept		json
@Produce	json
@Param		topic_id	path		string	true	"Topic id"
@Success	200			{object}	topicResponse
@Failure	404			{object}	errorResponse
@Failure	500			{object}	errorResponse
@Router		/topics/{topic_id} [get]

func (*TopicHandler) List added in v0.2.0

func (t *TopicHandler) List(c *gin.Context)

List topics.

@Summary	List topics
@Tags		topics
@Accept		json
@Produce	json
@Param		limit	query		int	false	"The limit indicates the maximum number of items to return"
@Param		offset	query		int	false	"The offset indicates the starting position of the query in relation to the complete set of unpaginated items"
@Success	200		{object}	topicListResponse
@Failure	500		{object}	errorResponse
@Router		/topics [get]

Jump to

Keyboard shortcuts

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