server

package
v0.0.0-...-aa3fb43 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is configured by the caller with the Option functions.

type Option

type Option func(config *Config) error

Option is used to configure the HTTP server.

func WithConfigProvider

func WithConfigProvider(provider func() (*config.HTTPServer, error)) Option

WithConfigProvider sets the provider for the config.HTTPServer.

func WithListenerProvider

func WithListenerProvider(provider func(localHost string, localPort uint16) (tcp.Listener, error)) Option

WithListenerProvider sets the provider for the tcp.Listener.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server handles requests via the Hypertext Transfer Protocol (HTTP) and sends back responses. The Server must be allocated using New since the zero value for Server is not valid configuration.

func New

func New(opts ...Option) (*Server, error)

New allocates and sets the required configuration for a Server.

func (*Server) Run

func (server *Server) Run(commonMiddleware []middleware.Middleware, endpointHandlers []api.HTTPEndpointHandler, readyCallback func()) error

Run configures and starts an HTTP server. After the HTTP server is bound to its IP and port, it invokes the callback function. This function blocks as long as it is serving HTTP.

func (*Server) Shutdown

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

Shutdown gracefully shuts down the server and waits for it to finish. This function can be called concurrently, but the first will perform the shutdown action.

Jump to

Keyboard shortcuts

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