api

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiConfig

type ApiConfig struct {
	DB *gorm.DB
}

ApiConfig holds the API handler configuration

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.

type WsHub

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

Hub maintains the set of active clients and broadcasts messages to the clients.

func NewWsHub

func NewWsHub() *WsHub

type WsMessage

type WsMessage struct {
	Topic   string `json:"topic"`
	Payload any    `json:"payload"`
}

Jump to

Keyboard shortcuts

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