Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiHandler ¶
type ApiHandler struct {
// contains filtered or unexported fields
}
ApiHandler represents the API handler
func NewHandler ¶
func NewHandler(config *ApiConfig) *ApiHandler
NewHandler creates a new API handler instance
func (*ApiHandler) Publish ¶
func (h *ApiHandler) Publish(topic string, payload any)
Publish sends a message to all subscribed clients of a topic. It is non-blocking; if the broadcast channel is full, the message will be dropped.
func (*ApiHandler) RegisterRoutes ¶
func (h *ApiHandler) RegisterRoutes(mux *http.ServeMux)
RegisterRoutes configures all API routes on the provided mux
func (*ApiHandler) WsBroadcast ¶
func (h *ApiHandler) WsBroadcast(v any)
WsBroadcast sends a generic message to all connected WebSocket clients. It is non-blocking; if the broadcast channel is full, the message will be dropped.
type RequestPayload ¶
type RequestPayload struct {
Method string `json:"method"`
URL string `json:"url"`
Headers map[string]string `json:"headers"`
Body string `json:"body"`
}
RequestPayload represents the incoming request from the UI when sent as JSON
type ResponsePayload ¶
type ResponsePayload struct {
Status int `json:"status"`
StatusText string `json:"statusText"`
Headers map[string]string `json:"headers"`
Body []byte `json:"body"`
Duration int64 `json:"duration"` // in milliseconds
}
ResponsePayload represents the response to send back to the UI
type WsClient ¶
type WsClient struct {
// contains filtered or unexported fields
}
Client is a middleman between the websocket connection and the hub.