server

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OKDoneErr = errors.New("route done")
View Source
var OKNotDoneErr = errors.New("not done")

Functions

This section is empty.

Types

type FailableHandler added in v1.3.0

type FailableHandler func(w http.ResponseWriter, r *http.Request) error

FailableHandler is an http.HandlerFunc that returns an error. oneshot uses this error to determine when to exit.

type Route

type Route struct {
	Pattern         string
	Methods         []string
	HandlerFunc     FailableHandler
	DoneHandlerFunc http.HandlerFunc
	MaxOK           int64
	MaxRequests     int64

	sync.Mutex
	// contains filtered or unexported fields
}

func (*Route) OkCount

func (r *Route) OkCount() int64

func (*Route) RequestCount

func (r *Route) RequestCount() int64

type Server

type Server struct {
	Host string
	Port string

	// Certfile is the public certificate that should be used for TLS
	CertFile string
	// Keyfile is the private key that should be used for TLS
	KeyFile string

	// Done signals when the server has shutdown regardless of value.
	// Each route that finished will have an error message in the map.
	// Routes that finish successfully will have an OKDoneErr error.
	Done chan map[*Route]error

	ErrorLog *log.Logger
	InfoLog  *log.Logger

	HostAddresses []string

	sync.Mutex
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

func (*Server) AddRoute

func (s *Server) AddRoute(route *Route)

AddRoute adds a new single fire route to the server.

func (*Server) Close

func (s *Server) Close() error

func (*Server) HandleIcon added in v1.4.1

func (s *Server) HandleIcon(w http.ResponseWriter, r *http.Request)

func (*Server) Serve

func (s *Server) Serve() error

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Shutdown

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

Jump to

Keyboard shortcuts

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