server

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2018 License: Apache-2.0, BSD-3-Clause, MIT Imports: 10 Imported by: 3

Documentation

Overview

Package server contains the logic of the Service Manager server and a mux router

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	*mux.Router

	Config *Settings
}

Server is the server to process incoming HTTP requests

func New

func New(config *Settings, api *web.API) *Server

New creates a new server with the provided REST api configuration and server configuration Returns the new server and an error if creation was not successful

func (*Server) Run

func (s *Server) Run(ctx context.Context)

Run starts the server awaiting for incoming requests

type Settings

type Settings struct {
	Host            string        `mapstructure:"host" description:"host of the server"`
	Port            int           `mapstructure:"port" description:"port of the server"`
	RequestTimeout  time.Duration `mapstructure:"request_timeout" description:"read and write timeout duration for requests"`
	ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout" description:"time to wait for the server to shutdown"`
	MaxBodyBytes    int           `mapstructure:"max_body_bytes" description:"maximum bytes size of incoming body"`
	MaxHeaderBytes  int           `mapstructure:"max_header_bytes" description:"the maximum number of bytes the server will read parsing the request header"`
}

Settings type to be loaded from the environment

func DefaultSettings

func DefaultSettings() *Settings

DefaultSettings returns the default values for configuring the Service Manager

func NewSettings

func NewSettings(env env.Environment) (*Settings, error)

NewSettings returns Server settings for the given enrivonment

func (*Settings) Validate

func (s *Settings) Validate() error

Validate validates the server settings

Jump to

Keyboard shortcuts

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