server

package
v0.0.0-...-bcf6333 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListenerFactory

type ListenerFactory interface {
	//Listener should return a new net.Listener that is open and available for use
	//or an error if there is a failure.
	Listener() (net.Listener, error)
}

ListenerFactory provides the Listener method that is used to create a net.Listener.

type PortListenerFactory

type PortListenerFactory int

PortListenerFactory is a ListenerFactory that returns a Listener by listening via tcp4 on the loopback interface and the port represented by this value.

func (PortListenerFactory) Listener

func (f PortListenerFactory) Listener() (net.Listener, error)

Listener returns a tcp listener listening on the loopback interface and the port f.

Note that a value of 0 is useful for testing and allows the system to select an open port.

type Server

type Server struct {
	//ListenerFactory is the promoted factory used to create a Listener.
	//Must not be nil.
	ListenerFactory
	// contains filtered or unexported fields
}

Server is a wrapper for the http.Server to use in the application.

func (*Server) Serve

func (s *Server) Serve(h http.Handler) error

Serve attempts to serve h on the Listener returned from s.ListenerFactory. If a Listener could not be created, then that error is returned immediately. Otherwise, an http.Server is created to use h and its Serve method is called with the new Listener.

The new Listener is closed before this method returns.

A non-nil error means serving has failed in some way. If s is stoped via a call to s.Shutdown, then the error returned should be nil if nothing went wrong during the shutdown process.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown attempts to stop s.

Jump to

Keyboard shortcuts

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