server

package
v1.4.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Host is a default bind address for HTTP servers
	Host string = "localhost"
	// SSL is a default configuration for HTTP servers
	SSL *SSLConfig
	// MaxConn is a default configuration for maximum connections
	MaxConn int
)

Functions

func HealthHandler added in v1.0.1

func HealthHandler(w http.ResponseWriter, _ *http.Request)

HealthHandler always reponds with 200 status

Types

type HTTPServer

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

HTTPServer is wrapper over http.Server

func ForPort added in v1.0.1

func ForPort(port string) (*HTTPServer, error)

ForPort creates new or returns the existing server for the specified port

func NewServer

func NewServer(host string, port string, ssl *SSLConfig, maxConn int) (*HTTPServer, error)

NewServer builds HTTPServer from config params

func (*HTTPServer) Address

func (s *HTTPServer) Address() string

Address returns server scheme://host:port

func (*HTTPServer) Running added in v1.0.1

func (s *HTTPServer) Running() bool

Running returns true if server has been started

func (*HTTPServer) SetupHandler added in v1.3.0

func (s *HTTPServer) SetupHandler(path string, handler http.Handler)

SetupHandler adds new handler to mux

func (*HTTPServer) Shutdown added in v1.1.0

func (s *HTTPServer) Shutdown() error

Shutdown shuts down server gracefully.

func (*HTTPServer) Start

func (s *HTTPServer) Start() error

Start server

func (*HTTPServer) StartAndAnnounce added in v1.0.1

func (s *HTTPServer) StartAndAnnounce(name string) error

StartAndAnnounce prints server info and starts server

func (*HTTPServer) Stopped

func (s *HTTPServer) Stopped() bool

Stopped return true iff server has been stopped by user

type SSLConfig added in v1.0.1

type SSLConfig struct {
	CertPath string
	KeyPath  string
}

SSLConfig contains SSL parameters

func NewSSLConfig added in v1.0.1

func NewSSLConfig() SSLConfig

NewSSLConfig build a new SSLConfig struct

func (*SSLConfig) Available added in v1.0.1

func (opts *SSLConfig) Available() bool

Available returns true iff certificate and private keys are set

Jump to

Keyboard shortcuts

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