api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package api provides HTTP handlers for the PubSub server REST API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Error   string `json:"error"`
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

ErrorResponse represents an error response.

type Handler

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

Handler holds dependencies for API handlers.

func NewHandler

func NewHandler(
	publisher *pubsub.Publisher,
	subscriptionManager *pubsub.SubscriptionManager,
	logger pubsub.Logger,
) *Handler

NewHandler creates a new API handler.

func (*Handler) HandleHealth

func (h *Handler) HandleHealth(w http.ResponseWriter, r *http.Request)

HandleHealth handles GET /api/v1/health

func (*Handler) HandleListSubscriptions

func (h *Handler) HandleListSubscriptions(w http.ResponseWriter, r *http.Request)

HandleListSubscriptions handles GET /api/v1/subscriptions

func (*Handler) HandlePublish

func (h *Handler) HandlePublish(w http.ResponseWriter, r *http.Request)

HandlePublish handles POST /api/v1/publish

func (*Handler) HandleSubscribe

func (h *Handler) HandleSubscribe(w http.ResponseWriter, r *http.Request)

HandleSubscribe handles POST /api/v1/subscribe

func (*Handler) HandleUnsubscribe

func (h *Handler) HandleUnsubscribe(w http.ResponseWriter, r *http.Request)

HandleUnsubscribe handles DELETE /api/v1/subscriptions/:id

type PublishRequest

type PublishRequest struct {
	TopicCode  string                 `json:"topicCode"`
	Identifier string                 `json:"identifier"`
	Data       map[string]interface{} `json:"data"`
}

PublishRequest represents a publish message request.

type SubscribeRequest

type SubscribeRequest struct {
	SubscriberID int64  `json:"subscriberID"`
	TopicCode    string `json:"topicCode"`
	Identifier   string `json:"identifier"`
}

SubscribeRequest represents a subscription creation request.

type SuccessResponse

type SuccessResponse struct {
	Success bool        `json:"success"`
	Data    interface{} `json:"data,omitempty"`
	Message string      `json:"message,omitempty"`
}

SuccessResponse represents a success response.

Jump to

Keyboard shortcuts

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