HTTP handler for _dumpchannel
()
| 355 | |
| 356 | // HTTP handler for _dumpchannel |
| 357 | func (h *handler) handleDumpChannel() error { |
| 358 | channelName := h.PathVar("channel") |
| 359 | since := h.getIntQuery("since", 0) |
| 360 | base.InfofCtx(h.ctx(), base.KeyHTTP, "Dump channel %q", base.UD(channelName)) |
| 361 | |
| 362 | chanLog, _ := h.collection.GetChangeLog(h.ctx(), ch.NewID(channelName, h.collection.GetCollectionID()), since) |
| 363 | if chanLog == nil { |
| 364 | return base.HTTPErrorf(http.StatusNotFound, "no such channel") |
| 365 | } |
| 366 | title := fmt.Sprintf("/%s: “%s” Channel", html.EscapeString(h.db.Name), html.EscapeString(channelName)) |
| 367 | h.setHeader("Content-Type", `text/html; charset="UTF-8"`) |
| 368 | _, _ = h.response.Write([]byte(fmt.Sprintf( |
| 369 | `<!DOCTYPE html><html><head><title>%s</title></head><body> |
| 370 | <h1>%s</h1><code> |
| 371 | <p>Since = %d</p> |
| 372 | <table border=1> |
| 373 | `, |
| 374 | title, title, chanLog[0].Sequence-1))) |
| 375 | _, _ = h.response.Write([]byte("\t<tr><th>Seq</th><th>Doc</th><th>Rev</th><th>Flags</th></tr>\n")) |
| 376 | for _, entry := range chanLog { |
| 377 | _, _ = h.response.Write([]byte(fmt.Sprintf("\t<tr><td>%d</td><td>%s</td><td>%s</td><td>%08b</td>", |
| 378 | entry.Sequence, |
| 379 | html.EscapeString(entry.DocID), html.EscapeString(entry.RevID), entry.Flags))) |
| 380 | _, _ = h.response.Write([]byte("</tr>\n")) |
| 381 | } |
| 382 | _, _ = h.response.Write([]byte("</table>\n</code></html></body>")) |
| 383 | return nil |
| 384 | } |
| 385 | |
| 386 | // HTTP handler for a POST to _bulk_get |
| 387 | // Request looks like POST /db/_bulk_get?revs=___&attachments=___ |
nothing calls this directly
no test coverage detected