http

package
v1.0.1-0...-32d7d0a Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Unlicense Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultServerConfig = ServerConfig{
		Domain:          "",
		Host:            "localhost",
		Port:            "8001",
		H2C:             false,
		ReadTimeout:     5 * time.Second,
		WriteTimeout:    10 * time.Second,
		IdleTimeout:     10 * time.Second,
		ShutdownTimeout: 1 * time.Second,
		Controller:      DefaultControllerConfig,
	}
	DefaultMiddlewareConfig = MiddlewareConfig{
		CorsAllowOrigin: "",
		WriteTimeout:    10 * time.Second,
		MaxFileSize:     512 * kb,
		Debug:           false,
	}
	DefaultControllerConfig = ControllerConfig{
		MaxNumberOfFiles: 3,
		MaxFileSize:      512 * kb,
	}
)
View Source
var (
	ErrServerClosed = http.ErrServerClosed
)

Functions

This section is empty.

Types

type ControllerConfig

type ControllerConfig struct {
	MaxNumberOfFiles int   `mapstructure:"CONTROLLER_MAX_NUMBER_OF_FILES" validate:"required"`
	MaxFileSize      int64 `mapstructure:"CONTROLLER_MAX_FILE_SIZE"       validate:"required"`
}

type Middleware

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

func NewMiddleware

func NewMiddleware(
	conf MiddlewareConfig,
	lim domain.Limiter,
) *Middleware

func (*Middleware) Chain

func (m *Middleware) Chain(h http.Handler) http.Handler

type MiddlewareConfig

type MiddlewareConfig struct {
	CorsAllowOrigin string        `mapstructure:"MIDDLEWARE_CORS_ALLOW_ORIGIN" validate:"required"`
	WriteTimeout    time.Duration `mapstructure:"SERVER_WRITE_TIMEOUT"         validate:"required"`
	MaxFileSize     int64         `mapstructure:"CONTROLLER_MAX_FILE_SIZE"     validate:"required"`
	Debug           bool          `mapstructure:"MIDDLEWARE_DEBUG"`
}

type Server

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

func NewServer

func NewServer(
	conf ServerConfig,
	middle func(http.Handler) http.Handler,
	serv domain.Servicer,
	serverWait chan<- error,
) (*Server, error)

func (*Server) Monitor

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

func (*Server) Start

func (s *Server) Start() error

type ServerConfig

type ServerConfig struct {
	Domain          string           `mapstructure:"SERVER_DOMAIN"`
	Host            string           `mapstructure:"SERVER_HOST"`
	Port            string           `mapstructure:"SERVER_PORT"             validate:"required"`
	H2C             bool             `mapstructure:"SERVER_H2C"`
	ReadTimeout     time.Duration    `mapstructure:"SERVER_READ_TIMEOUT"     validate:"required"`
	WriteTimeout    time.Duration    `mapstructure:"SERVER_WRITE_TIMEOUT"    validate:"required"`
	IdleTimeout     time.Duration    `mapstructure:"SERVER_IDLE_TIMEOUT"     validate:"required"`
	ShutdownTimeout time.Duration    `mapstructure:"SERVER_SHUTDOWN_TIMEOUT" validate:"required"`
	Controller      ControllerConfig `mapstructure:",squash"`
}

Jump to

Keyboard shortcuts

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