MCPcopy Create free account
hub / github.com/cli/cli / startServer

Function startServer

script/ghmock/server.go:49–65  ·  view source on GitHub ↗
(st *state, chk *checker, ca *certAuthority, git *gitBackend)

Source from the content-addressed store, hash-verified

47}
48
49func startServer(st *state, chk *checker, ca *certAuthority, git *gitBackend) (*mockServer, error) {
50 ln, err := net.Listen("tcp", "127.0.0.1:0")
51 if err != nil {
52 return nil, err
53 }
54 m := &mockServer{state: st, checker: chk, ca: ca, git: git, listener: ln, cursors: map[string]int{}}
55 m.srv = &http.Server{Handler: m, ReadHeaderTimeout: 10 * time.Second}
56 if ca != nil {
57 m.tunnels = newTunnelListener(ln.Addr())
58 m.tunnelSrv = &http.Server{Handler: m, ReadHeaderTimeout: 10 * time.Second}
59 }
60 go func() { _ = m.srv.Serve(ln) }()
61 if m.tunnelSrv != nil {
62 go func() { _ = m.tunnelSrv.Serve(m.tunnels) }()
63 }
64 return m, nil
65}
66
67// check records what the schema check found for a request and its response.
68func (m *mockServer) check(entry *loggedRequest, resp *response) {

Callers 3

TestMockServerFunction · 0.85
runBinaryFunction · 0.85
cmdGitFunction · 0.85

Calls 2

newTunnelListenerFunction · 0.85
AddrMethod · 0.80

Tested by 1

TestMockServerFunction · 0.68