httpd

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Overview

Package httpd implements an HTTP server with a complete lifecycle. The name httpd stands for HTTP daemon.

Index

Constants

View Source
const DisabledTimeout time.Duration = -1

DisabledTimeout is a special value that indicates that a timeout is disabled. It will effectively set the timeout to a 0 value. It is used to override the default timeouts.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Interface string
	Port      string

	ReadHeaderTimeout time.Duration
	ReadTimeout       time.Duration
	IdleTimeout       time.Duration
	WriteTimeout      time.Duration
	ShutdownTimeout   time.Duration
}

Config contains server setup.

type Server

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

Server implements an HTTP server with a complete lifecycle.

func NewServer

func NewServer(cfg Config, handler http.Handler) (*Server, error)

NewServer creates a new server.

func (*Server) Address

func (s *Server) Address() string

Address returns the server address.

func (*Server) Run

func (s *Server) Run() error

Run runs the server. It blocks until the server is stopped.

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the server gracefully. It blocks until all connections are closed. It returns an error if the server is already stopped or if the shutdown timeout is reached.

func (*Server) Unbind

func (s *Server) Unbind() error

Unbind unbinds the server from the listening address. Existing connections are not closed. New connections are rejected. It returns an error if the server is already unbound.

Jump to

Keyboard shortcuts

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