MCPcopy Create free account
hub / github.com/cairoeth/preconfirmations / startMainServer

Method startMainServer

rpc/server/server.go:160–180  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

158}
159
160func (s *RPCEndPointServer) startMainServer() {
161 if s.server != nil {
162 panic("http server is already running")
163 }
164 // Handler for root URL (JSON-RPC on POST, public/index.html on GET)
165 mux := http.NewServeMux()
166 mux.HandleFunc("/", s.HandleHTTPRequest)
167 mux.HandleFunc("/health", s.handleHealthRequest)
168 mux.HandleFunc("/bundle", s.HandleBundleRequest)
169 s.server = &http.Server{
170 Addr: s.listenAddress,
171 Handler: mux,
172 WriteTimeout: 30 * time.Second,
173 ReadTimeout: 30 * time.Second,
174 }
175 go func() {
176 if err := s.server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
177 s.logger.Error("http server failed", zap.Error(err))
178 }
179 }()
180}
181
182func (s *RPCEndPointServer) stopMainServer() {
183 if s.server != nil {

Callers 1

StartMethod · 0.95

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected