http

package
v2.11.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

func CORSMiddleware(next http.Handler, origins []string, passPreflight ...string) http.Handler

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

func ParseWindow(v string) (time.Duration, error)

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

type AuthSettings struct {
	Enabled  bool
	LoginURL string
}

AuthSettings holds auth info exposed via /api/settings.

type DetectedEvent

type DetectedEvent struct {
	Type    string
	Project string
}

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 NewEventService(store event.Store, hub *ws.Hub, registry *module.Registry, m *metrics.Collector, db *sql.DB) *EventService

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

func (s *EventService) HandleIncoming(ctx context.Context, inc *event.Incoming) error

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.

Jump to

Keyboard shortcuts

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