server

package
v0.0.0-...-cf2fde9 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultHeaders

func DefaultHeaders(w http.ResponseWriter)

func DefaultLogger

func DefaultLogger() *logrus.Entry

DefaultLogger builds a default logrus logger

Pre-Condition: - None Post-Condition: - None Params: - None Returns: - logrus entry as a logger Errors: - None Dev Notes: - None

Types

type Config

type Config struct {
	Port   int
	Log    *logrus.Entry
	Logger *logrus.Logger
}

Config contains settings and configurations support various server integrations. Implements pkg.Config

func (Config) String

func (c Config) String() string

String provides a string representation of the state of this struct

Pre-Condition: - None Post-Condition: - None Params: - None Returns: - string representation Errors: - None Dev Notes: - None

func (Config) Validate

func (c Config) Validate() (bool, error)

Validate verifys that - required config attributes are set - attributes that are provided have valid values

Pre-Condition: - None Post-Condition: - None Params: - None Returns: - true if valid configs provided, otherwise false Errors: - if Config is not initialized - if one or more errors are detected Dev Notes: - None

type Options

type Options struct {
	HasProfiling bool
	HasPush      bool
	CertFile     string
	KeyFile      string
	Timeout      int

} //of Options

Options contains feature switches to support various server integrations. This implements pkg.Options

func (*Options) LoadDefaults

func (o *Options) LoadDefaults()

LoadDefaults loads any default option values

Pre-Condition: - Options are initialized Post-Condition: - Sets HashPush feature flag based on presense and finding cert and key files Params: - None Returns: - None Errors: - None Dev Notes: - The HasPush feature flag is Read Only. The cert and key files must be valid before it toggles to true

func (Options) String

func (o Options) String() string

String provides a string representation of the state of this struct

Pre-Condition: - None Post-Condition: - None Params: - None Returns: - string representation Errors: - None Dev Notes: - None

func (Options) Validate

func (o Options) Validate() (bool, error)

Validate verifys that - required option attributes are set - attributes that are provided have valid values

Pre-Condition: - None Post-Condition: - None Params: - None Returns: - true if valid options provided, otherwise false Errors: - if one or more errors are detected Dev Notes: - None

type Server

type Server struct {
	Options
	Config
	// contains filtered or unexported fields

} //of Server

Server provides http(s) support to this application. Set options for feature flags and Configs for env/system configurations

func NewServer

func NewServer(opts Options, conf Config) (s Server, e error)

NewServer initializes a new server based on options and configs provided

Pre-Condition: - None Post-Condition: - None Params: - opts Options or feature flags supported for this server - conf Config or required settings for this server Returns: - instance of server - errors if any Errors: - invalid port provided Dev Notes: - None

func (*Server) RegisterHandler

func (s *Server) RegisterHandler(path string, handler http.Handler)

RegisterHandler allow clients to register new routes/paths

Pre-Condition: - Server is initialized - Server has valid options - Server has valid configs Post-Condition: - router has new path with associated Handler Params: - path string subpath for this route - handler Handler that will apply logic for request and associated response Returns: - None Errors: - None Dev Notes: - None

func (Server) Run

func (s Server) Run(wg *sync.WaitGroup) (srv *http.Server, err error)

Run Starts the server with routes based on the provided configurations and options. If cert and key info is provided in options, the server will start as an TLS (Push) server.

Pre-Condition: - Server is initialized - Server has valid options - Server has valid configs Post-Condition: - server is running and able to accept requests Params: - None Returns: - Error Errors: - if certs/TLS is indicated but not found - if errors while starting TLS server support - if errors while starting non-TLS server support Dev Notes: - None

func (Server) String

func (s Server) String() string

String provides a string representation of the state of this struct

Pre-Condition: - None Post-Condition: - None Params: - None Returns: - string representation Errors: - None Dev Notes: - None

Jump to

Keyboard shortcuts

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