(hl blobserver.FindHandlerByTyper)
| 69 | } |
| 70 | |
| 71 | func (sh *StatusHandler) InitHandler(hl blobserver.FindHandlerByTyper) error { |
| 72 | _, h, err := hl.FindHandlerByType("search") |
| 73 | if err == blobserver.ErrHandlerTypeNotFound { |
| 74 | return nil |
| 75 | } |
| 76 | if err != nil { |
| 77 | return err |
| 78 | } |
| 79 | go func() { |
| 80 | var lastSend *status |
| 81 | for { |
| 82 | cur := sh.currentStatus() |
| 83 | if reflect.DeepEqual(cur, lastSend) { |
| 84 | // TODO: something better. get notified on interesting events. |
| 85 | time.Sleep(10 * time.Second) |
| 86 | continue |
| 87 | } |
| 88 | lastSend = cur |
| 89 | js, _ := json.MarshalIndent(cur, "", " ") |
| 90 | h.(*search.Handler).SendStatusUpdate(js) |
| 91 | } |
| 92 | }() |
| 93 | return nil |
| 94 | } |
| 95 | |
| 96 | func (sh *StatusHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { |
| 97 | suffix := httputil.PathSuffix(req) |
nothing calls this directly
no test coverage detected