httpserver

package
v0.0.0-...-fa23fe4 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB int64 = 1 << (10 * iota)
	MB
	GB
	TB
)

Data size units.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ServerAddr         string
	AccessLogEnabled   bool
	AccessLogSkipPaths []string
	ReadTimeout        time.Duration
	ReadHeaderTimeout  time.Duration
	WriteTimeout       time.Duration
	TLSCrtFile         string
	TLSKeyFile         string
	TLSCAFile          string
}

type Server

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

func NewServer

func NewServer(cfg *Config) *Server

NewHTTPServer creates a new HTTP server with the given configuration.

It takes a pointer to a Config struct as a parameter. It returns a pointer to an httpServer struct.

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown shuts down the HTTP server.

It uses a context with a timeout of 5 seconds to gracefully shutdown the server. It returns an error if the server fails to shutdown.

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP server.

It does not take any parameters. It returns an error.

func (*Server) StartTLS

func (s *Server) StartTLS() error

Jump to

Keyboard shortcuts

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