package main import ( "context" "net/http" "github.com/food-ai/backend/internal/domain/recognition" ) // App bundles the HTTP handler with background services that need lifecycle management. type App struct { handler http.Handler sseBroker *recognition.SSEBroker productSSEBroker *recognition.ProductSSEBroker } // ServeHTTP implements http.Handler. func (application *App) ServeHTTP(responseWriter http.ResponseWriter, request *http.Request) { application.handler.ServeHTTP(responseWriter, request) } // Start launches the SSE brokers' LISTEN loops. // Call this once before the HTTP server begins accepting connections. func (application *App) Start(applicationContext context.Context) { application.sseBroker.Start(applicationContext) application.productSSEBroker.Start(applicationContext) }