restserver

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrAddressEmpty        string = "address is empty"
	ErrPortEmpty           string = "port is empty"
	ErrPortBadf            string = "port is a non-integer: %s"
	ErrShutdownTimeoutBadf string = "shutdown timeout is lte to 0: %v"
)
View Source
const (
	EnvNameAddress          string = "BLUDGEON_REST_ADDRESS"
	EnvNamePort             string = "BLUDGEON_REST_PORT"
	EnvNameShutdownTimeout  string = "BLUDGEON_REST_SHUTDOWN_TIMEOUT"
	EnvNameAllowCredentials string = "BLUDGEON_ALLOW_CREDENTIALS"
	EnvNameAllowedOrigins   string = "BLUDGEON_ALLOWED_ORIGINS"
	EnvNameAllowedMethods   string = "BLUDGEON_ALLOWED_METHODS"
	EnvNameCorsDebug        string = "BLUDGEON_CORS_DEBUG"
	EnvNameCorsDisabled     string = "BLUDGEON_DISABLE_CORS"
)
View Source
const (
	DefaultAddress          string        = "127.0.0.1"
	DefaultPort             string        = "8080"
	DefaultShutdownTimeout  time.Duration = 10 * time.Second
	DefaultAllowCredentials bool          = true
	DefaultCorsDebug        bool          = false
)
View Source
const (
	ErrStarted    string = "already started"
	ErrNotStarted string = "not started"
)

Variables

This section is empty.

Functions

func Vars added in v1.2.1

func Vars(request *http.Request) map[string]string

Types

type Configuration

type Configuration struct {
	Address          string        `json:"address"`
	Port             string        `json:"port"`
	Timeout          time.Duration `json:"timeout"`
	ShutdownTimeout  time.Duration `json:"shutdown_timeout"`
	AllowedOrigins   []string      `json:"allowed_origins"`
	AllowedMethods   []string      `json:"allowed_methods"`
	AllowCredentials bool          `json:"allow_credentials"`
	CorsDebug        bool          `json:"cors_debug"`
	CorsDisabled     bool          `json:"cors_disabled"`
}

func (*Configuration) FromEnv

func (c *Configuration) FromEnv(envs map[string]string)

func (*Configuration) Validate

func (c *Configuration) Validate() (err error)

type HandleFuncConfig

type HandleFuncConfig struct {
	Route    string
	Method   string
	HandleFx func(http.ResponseWriter, *http.Request)
}

type RouteBuilder added in v1.4.0

type RouteBuilder interface {
	BuildRoutes() []HandleFuncConfig
}

Jump to

Keyboard shortcuts

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