server

package
v0.0.0-...-a1990c1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server is a http server. Can be started with Start method. Gracefully stops when context is canceled. Must be initialized with New function.

func New

func New(settings Settings) *Server

New initializes and returns a new Server instance based on the provided settings. It configures the server address and handler, and sets the shutdown timeout to a default value.

func (*Server) Start

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

Start starts the server. It returns an error if it fails to start the server. The error is not returned if the context is canceled, the server is shutdown and the shutdown is successful.

The server is shutdown when the context is canceled. The shutdown is cancelled if the server failed to start.

type Settings

type Settings struct {
	Addr    string
	Handler http.Handler
}

Settings used to create Server. Settings must be provided to New function. All fields are required and cant be nil.

Jump to

Keyboard shortcuts

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