tuna

package
v0.0.0-...-89fb8e2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "R7"

Version holds the version numer of MaguroHTTP

Variables

This section is empty.

Functions

func LoadConfigFromFile

func LoadConfigFromFile(p string, c *Config)

LoadConfigFromFile is a function which a loads the Config type microConfig from a json file

Types

type AutoCertConfig

type AutoCertConfig struct {
	Enabled      bool
	Certificates []string
}

AutoCertConfig is part of MaguroHTTP core/tls configuration

type Config

type Config struct {
	Core   CoreConfig
	Serve  serveConfig
	Errors map[string]string
	Proxy  proxyConfig
	Guard  guardConfig
}

Config is type holding the main configurtion

func NewConfig

func NewConfig() Config

NewConfig returns a pointer to a config, initialised with default values

func NewVhostConfig

func NewVhostConfig() Config

NewVhostConfig returns a pointer to a config, initialised with default values

func (*Config) Validate

func (c *Config) Validate(p string, isVhost bool)

Validate can be used to validate a Config type

type CoreConfig

type CoreConfig struct {
	Address  string
	Port     string
	FileDir  string
	LogLevel int
	LogOut   string

	ReadTimeout       int
	ReadHeaderTimeout int
	WriteTimeout      int

	WebDAV         bool
	VirtualHosting bool
	VirtualHosts   map[string]string
	TLS            TLSConfig
	Metrics        MetricsConfig
}

CoreConfig is part of the main configuration. coreConfig is not used by vhosts

type HSTSConfig

type HSTSConfig struct {
	MaxAge            int
	Preload           bool
	IncludeSubdomains bool
}

HSTSConfig type, part of MaguroHTTP core/tls config

type MIMETypes

type MIMETypes struct {
	ResponseTypes map[string]string
	RequestTypes  map[string]string
}

MIMETypes type, part of MaguroHTTP serveConfig

type MetricsConfig

type MetricsConfig struct {
	Enabled bool
	Path    string
	Out     string
	Users   map[string]string
}

MetricsConfig type, part of MaguroHTTP config

type Server

type Server struct {

	// Cfg is of type Config and holds the configuration of instance
	Cfg Config

	// vhosts holds the information of each vhost
	Vhosts map[string]Config

	// Router holds the router of the server instance
	Router *router.SRouter

	// HTTP transport
	Transport http.RoundTripper
	// contains filtered or unexported fields
}

Server is a type holding a MaguroHTTP server instance

func NewInstance

func NewInstance(c CoreConfig) *Server

NewInstance returns a pointer to a new MaguroHTTP server based on supplied config

func NewInstanceFromConfig

func NewInstanceFromConfig(p string) *Server

NewInstanceFromConfig will create a new instance from a config file

func (*Server) HandleError

func (s *Server) HandleError(w http.ResponseWriter, r *http.Request, errorCode int)

HandleError is a function to write HTTP error to ResponseWriter

func (*Server) Log

func (s *Server) Log(logLevel int, err error)

Log is a function to log messages using the debug.Logger type

func (*Server) LogNetwork

func (s *Server) LogNetwork(statusCode int, r *http.Request)

LogNetwork is a function to log network activity using the debug.Logger type

func (*Server) Serve

func (s *Server) Serve()

Serve is used to serve a MaguroHTTP instance

func (*Server) WriteString

func (s *Server) WriteString(w io.Writer, str string)

WriteString is a wrapper function to write strings with incoperated error handling

type TLSConfig

type TLSConfig struct {
	Enabled   bool
	TLSCert   string
	TLSKey    string
	PrivateCA []string
	AutoCert  AutoCertConfig
	HSTS      HSTSConfig
}

TLSConfig holds information about TLS and is part of MaguroHTTP core config

Jump to

Keyboard shortcuts

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