httpserver

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: LGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package httpserver implements an HTTP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Info(msg string)
	Warn(msg string)
	Error(msg string)
}

Logger is the logger interface accepted by the HTTP server.

type Option

type Option func(s *optionalSettings)

Option is a functional option for the HTTP server.

func ReadHeaderTimeout

func ReadHeaderTimeout(timeout time.Duration) Option

ReadHeaderTimeout sets the header read timeout for the HTTP server. The default timeout is 1 second.

func ReadTimeout

func ReadTimeout(timeout time.Duration) Option

ReadTimeout sets the read timeout for the HTTP server. The default timeout is 10 seconds.

func ShutdownTimeout

func ShutdownTimeout(timeout time.Duration) Option

ShutdownTimeout sets an optional timeout for the HTTP server to shutdown. The default shutdown is 3 seconds.

type Server

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

Server is an HTTP server implementation, which uses the HTTP handler provided.

func New

func New(name, address string, handler http.Handler,
	logger Logger, options ...Option) *Server

New creates a new HTTP server with a name, listening on the address specified and using the HTTP handler provided.

func (*Server) GetAddress

func (s *Server) GetAddress() (address string)

GetAddress obtains the address the HTTP server is listening on.

func (*Server) Run

func (s *Server) Run(ctx context.Context, ready chan<- struct{}, done chan<- error)

Run runs the HTTP server until ctx is canceled. The done channel has an error written to when the HTTP server is terminated, and can be nil or not nil.

Jump to

Keyboard shortcuts

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