MCPcopy Create free account
hub / github.com/PasarGuard/node / GetLogs

Method GetLogs

controller/rest/log.go:8–39  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

6)
7
8func (s *Service) GetLogs(w http.ResponseWriter, r *http.Request) {
9 flusher, ok := w.(http.Flusher)
10 if !ok {
11 http.Error(w, "Streaming unsupported", http.StatusInternalServerError)
12 return
13 }
14
15 w.Header().Set("Content-Type", "text/event-stream")
16 w.Header().Set("Cache-Control", "no-cache")
17 w.Header().Set("Connection", "keep-alive")
18
19 logChan := s.Backend().Logs()
20
21 for {
22 select {
23 case log, ok := <-logChan:
24 if !ok {
25 return
26 }
27
28 _, err := fmt.Fprintf(w, "%s\n", log)
29 if err != nil {
30 return
31 }
32
33 flusher.Flush()
34
35 case <-r.Context().Done():
36 return
37 }
38 }
39}

Callers

nothing calls this directly

Implementers 1

Controllercontroller/controller.go

Calls 3

ErrorMethod · 0.80
BackendMethod · 0.80
LogsMethod · 0.65

Tested by

no test coverage detected