net

package
v1.72.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPServer

type HTTPServer struct {
	*http.Server
	// contains filtered or unexported fields
}

HTTPServer wraps an http.Server to listen asynchronously and allow stopping it.

func NewHTTPServer

func NewHTTPServer(s *http.Server) *HTTPServer

NewHTTPServer wraps the given http.Server into an HTTPServer.

func (*HTTPServer) ListenAndServe

func (h *HTTPServer) ListenAndServe() error

ListenAndServe starts the given HTTP server up in the background and returns immediately. The server listens on the configured Addr or ":http" if unconfigured.

An error is returned if the server failed to start up, if the server was already listening, or if the server was stopped with Stop().

func (*HTTPServer) Listener

func (h *HTTPServer) Listener() net.Listener

Listener returns the listener for this server or nil if the server isn't yet listening.

func (*HTTPServer) Serve added in v1.63.0

func (h *HTTPServer) Serve(lis net.Listener) error

Serve starts the HTTP server up in the background on the given listener and returns immediately.

An error is returned if the server failed to start up, if the server was already listening, or if the server was stopped with Stop().

func (*HTTPServer) Shutdown added in v1.33.0

func (h *HTTPServer) Shutdown(ctx context.Context) error

Shutdown stops the server. An error is returned if the server stopped unexpectedly.

Once a server is stopped, it cannot be started again with ListenAndServe.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL