39 lines
974 B
Go
39 lines
974 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"browser.local/platform/domain"
|
|
"browser.local/platform/dto"
|
|
"browser.local/platform/repo"
|
|
)
|
|
|
|
type liveLogRelayCore interface {
|
|
RelayLiveLogBatch(domain.LogBatchIngest) (domain.LogBatchIngestResult, error)
|
|
}
|
|
|
|
// runLiveLogRelay accepts current Run output and immediately fans it out to
|
|
// subscribers. It has no durable body or delivery acknowledgement contract.
|
|
func (h *coreHandlers) runLiveLogRelay(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodPost {
|
|
writeMethodNotAllowed(w, http.MethodPost)
|
|
return
|
|
}
|
|
core, ok := h.core.(liveLogRelayCore)
|
|
if !ok {
|
|
writeServiceError(w, repo.ErrNotFound)
|
|
return
|
|
}
|
|
request, err := decodeJSON[dto.LogBatchIngestRequest](r)
|
|
if err != nil {
|
|
writeDecodeError(w, err)
|
|
return
|
|
}
|
|
result, err := core.RelayLiveLogBatch(request.ToDomain())
|
|
if err != nil {
|
|
writeServiceError(w, err)
|
|
return
|
|
}
|
|
writeJSON(w, http.StatusOK, dto.LogBatchIngestFromDomain(result))
|
|
}
|