Documentation
¶
Index ¶
- Constants
- func CORSMiddleware(next http.Handler, origins []string, passPreflight ...string) http.Handler
- func ParseWindow(v string) (time.Duration, error)
- func RegisterAPI(mux *http.ServeMux, store event.Store, previews *event.PreviewRegistry, ...)
- func RegisterAttachmentAPI(mux *http.ServeMux, db *sql.DB, store *storage.AttachmentStore, ...)
- type AuthSettings
- type DetectedEvent
- type EventService
- type IngestionPipeline
- type ListLimits
Constants ¶
const ( // Internal headers set by the ingestion pipeline for handler matching. HeaderDetectedType = "X-Buggregator-Detected-Type" HeaderDetectedProject = "X-Buggregator-Detected-Project" )
Variables ¶
This section is empty.
Functions ¶
func CORSMiddleware ¶
CORSMiddleware adds CORS headers based on allowed origins. If origins contains "*", all origins are allowed. A preflight (OPTIONS) is answered here with 204, except under the passPreflight path prefixes: there it gets the CORS headers and goes on to the handler (the mock server, whose OPTIONS rules must see it).
func ParseWindow ¶
ParseWindow is time.ParseDuration plus the "d" suffix for days, which Go does not support but is the most common unit in a UI ("7d").
func RegisterAPI ¶
func RegisterAPI(mux *http.ServeMux, store event.Store, previews *event.PreviewRegistry, es *EventService, version string, db *sql.DB, enabledEvents []string, authSettings AuthSettings, authMiddleware func(http.Handler) http.Handler, listLimits ListLimits, updateStatus func() any, ports map[string]int)
RegisterAPI registers core API routes on the given mux. authMiddleware wraps protected routes; pass a no-op when auth is disabled. updateStatus gives the new-version check result for /api/settings; nil when the check is off. ports are the listen ports shown in /api/settings (name → port, only listeners that are on).
func RegisterAttachmentAPI ¶
func RegisterAttachmentAPI(mux *http.ServeMux, db *sql.DB, store *storage.AttachmentStore, protect func(http.Handler) http.Handler)
RegisterAttachmentAPI registers attachment list/download/preview endpoints.
Routes are namespaced under a literal `attachments` segment rather than `/api/{module}/{eventUuid}/attachments/...`. The previous layout used a wildcard at position 2, which collides with module routes like `/api/smtp/message/{uuid}/raw` (both 4-segment patterns, neither more specific) and made the server panic at startup.
The list goes through protect (the API auth): the UI fetches it with the token. Download and preview stay open: the UI opens them as plain links, which carry no X-Auth-Token, and each needs both the event and attachment UUIDs, which only the protected API hands out.
Types ¶
type AuthSettings ¶
AuthSettings holds auth info exposed via /api/settings.
type DetectedEvent ¶
DetectedEvent holds the event type and project extracted from the request.
type EventService ¶
type EventService struct {
// contains filtered or unexported fields
}
EventService handles the store -> preview -> broadcast -> notify pipeline.
func NewEventService ¶
func (*EventService) BroadcastCleared ¶
func (s *EventService) BroadcastCleared(eventType, project string)
BroadcastCleared broadcasts events cleared.
func (*EventService) BroadcastDeleted ¶
func (s *EventService) BroadcastDeleted(uuid, project string)
BroadcastDeleted broadcasts event deletion.
func (*EventService) HandleIncoming ¶
HandleIncoming stores an event, broadcasts preview, and notifies modules.
type IngestionPipeline ¶
type IngestionPipeline struct {
// contains filtered or unexported fields
}
IngestionPipeline tries each registered handler in priority order. Requests that aren't claimed by any module are served as static frontend files.
func NewIngestionPipeline ¶
func NewIngestionPipeline(handlers []module.HTTPIngestionHandler, es *EventService, frontendFS fs.FS) *IngestionPipeline
func (*IngestionPipeline) ServeHTTP ¶
func (p *IngestionPipeline) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ListLimits ¶
type ListLimits struct {
DefaultLimit int // how many events to return when limit is absent; 0 = unlimited
MaxLimit int // ceiling for an explicit limit; 0 = no ceiling
DefaultWindow time.Duration // time window applied when neither from/to nor window is given; 0 = no window
}
ListLimits bounds what /api/events and /api/events/preview return.
Both endpoints used to return every event matching type/project: Limit and Offset existed in FindOptions but were never filled in. On a busy project that is a very large response — measured on a production instance, a single project preview weighed 25.8 MB — which the frontend then filters in the browser.