MCPcopy
hub / github.com/etcd-io/etcd / ServeHTTP

Method ServeHTTP

client/pkg/testutil/pauseable_handler.go:28–45  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

26}
27
28func (ph *PauseableHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
29 ph.mu.Lock()
30 paused := ph.paused
31 ph.mu.Unlock()
32 if !paused {
33 ph.Next.ServeHTTP(w, r)
34 } else {
35 hj, ok := w.(http.Hijacker)
36 if !ok {
37 panic("webserver doesn't support hijacking")
38 }
39 conn, _, err := hj.Hijack()
40 if err != nil {
41 panic(err.Error())
42 }
43 conn.Close()
44 }
45}
46
47func (ph *PauseableHandler) Pause() {
48 ph.mu.Lock()

Callers

nothing calls this directly

Calls 4

LockMethod · 0.65
UnlockMethod · 0.65
ErrorMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected