server

package
v0.0.0-...-3e08555 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIDefinition

type APIDefinition interface {
	Start(r router.Router) error
	Stop()
}

APIDefinition is used to control lifecycle of the API

func APIFunc

func APIFunc(start func(router.Router) error, stop func()) APIDefinition

type Config

type Config struct {
	HealthPath string `split_words:"true"`
	Port       int
	TLS        nconf.TLSConfig
}

type HealthChecker

type HealthChecker interface {
	Healthy(w http.ResponseWriter, r *http.Request) *router.HTTPError
}

HealthChecker is used to run a custom health check Implement it on your API if you want it to be checked when the healthcheck is called

type Server

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

Server handles the setup and shutdown of the http server for an API

func New

func New(log logrus.FieldLogger, projectName string, config Config, api APIDefinition) (*Server, error)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

func (*Server) Shutdown

func (s *Server) Shutdown(to time.Duration) error

func (*Server) TestServer

func (s *Server) TestServer() *httptest.Server

Jump to

Keyboard shortcuts

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