Documentation
¶
Overview ¶
Package api provides HTTP handlers for the PubSub server REST API.
Index ¶
- type ErrorResponse
- type Handler
- func (h *Handler) HandleHealth(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleListSubscriptions(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandlePublish(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleSubscribe(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleUnsubscribe(w http.ResponseWriter, r *http.Request)
- type PublishRequest
- type SubscribeRequest
- type SuccessResponse
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.
Click to show internal directories.
Click to hide internal directories.