Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTimeouts = HTTPTimeouts{ ReadTimeout: 30 * time.Second, ReadHeaderTimeout: 30 * time.Second, WriteTimeout: 30 * time.Second, IdleTimeout: 120 * time.Second, }
DefaultTimeouts for HTTP server, based on the RPC timeouts that geth uses.
Functions ¶
Types ¶
type HTTPOption ¶ added in v1.2.0
type HTTPOption func(srv *HTTPServer) error
HTTPOption applies a change to an HTTP server
func WithMaxHeaderBytes ¶ added in v1.2.0
func WithMaxHeaderBytes(max int) HTTPOption
func WithTimeouts ¶ added in v1.2.0
func WithTimeouts(timeouts HTTPTimeouts) HTTPOption
type HTTPServer ¶ added in v1.2.0
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer wraps a http.Server, while providing conveniences like exposing the running state and address.
func StartHTTPServer ¶ added in v1.2.0
func StartHTTPServer(addr string, handler http.Handler, opts ...HTTPOption) (*HTTPServer, error)
func (*HTTPServer) Addr ¶ added in v1.2.0
func (s *HTTPServer) Addr() net.Addr
func (*HTTPServer) Close ¶ added in v1.2.0
func (s *HTTPServer) Close() error
Close force-closes the HTTPServer, its listener, and all its active connections.
func (*HTTPServer) Closed ¶ added in v1.2.0
func (s *HTTPServer) Closed() bool
func (*HTTPServer) Shutdown ¶ added in v1.2.0
func (s *HTTPServer) Shutdown(ctx context.Context) error
Shutdown shuts down the HTTP server and its listener, but allows active connections to close gracefully. If the function exits due to a ctx cancellation the listener is closed but active connections may remain, a call to Close() can force-close any remaining active connections.
type HTTPTimeouts ¶ added in v1.2.0
type HTTPTimeouts struct { // ReadTimeout is the maximum duration for reading the entire // request, including the body. A zero or negative value means // there will be no timeout. // // Because ReadTimeout does not let Handlers make per-request // decisions on each request body's acceptable deadline or // upload rate, most users will prefer to use // ReadHeaderTimeout. It is valid to use them both. ReadTimeout time.Duration // ReadHeaderTimeout is the amount of time allowed to read // request headers. The connection's read deadline is reset // after reading the headers and the Handler can decide what // is considered too slow for the body. If ReadHeaderTimeout // is zero, the value of ReadTimeout is used. If both are // zero, there is no timeout. ReadHeaderTimeout time.Duration // WriteTimeout is the maximum duration before timing out // writes of the response. It is reset whenever a new // request's header is read. Like ReadTimeout, it does not // let Handlers make decisions on a per-request basis. // A zero or negative value means there will be no timeout. WriteTimeout time.Duration // IdleTimeout is the maximum amount of time to wait for the // next request when keep-alives are enabled. If IdleTimeout // is zero, the value of ReadTimeout is used. If both are // zero, there is no timeout. IdleTimeout time.Duration }
HTTPTimeouts represents the configuration params for the HTTP RPC server.
type WrappedResponseWriter ¶
type WrappedResponseWriter struct { StatusCode int ResponseLen int // contains filtered or unexported fields }
func NewWrappedResponseWriter ¶
func NewWrappedResponseWriter(w http.ResponseWriter) *WrappedResponseWriter
func (*WrappedResponseWriter) Header ¶
func (w *WrappedResponseWriter) Header() http.Header
func (*WrappedResponseWriter) Write ¶
func (w *WrappedResponseWriter) Write(bytes []byte) (int, error)
func (*WrappedResponseWriter) WriteHeader ¶
func (w *WrappedResponseWriter) WriteHeader(statusCode int)
Click to show internal directories.
Click to hide internal directories.