settings

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MimeTypeJS  = mime.TypeApplicationJavascript
	MimeTypeCSS = mime.TypeTextCss
	MimeTypePNG = mime.TypeImagePng
)
View Source
const (
	FileExtJS  = ".js"
	FileExtCSS = ".css"
	FileExtPNG = ".png"
)
View Source
const (
	ErrFileIsNotSet           = "file is not set"
	ErrServerHostIsNotSet     = "server host is not set"
	ErrServerPortIsNotSet     = "server port is not set"
	ErrServerModeIsNotSet     = "server mode is not set"
	ErrServerMode             = "server mode error"
	ErrCertFileIsNotSet       = "certificate file is not set"
	ErrKeyFileIsNotSet        = "key file is not set"
	ErrHttpCacheControlMaxAge = "HTTP cache control max-age error"
)
View Source
const (
	ServerModeHttp    = "HTTP"
	ServerModeIdHttp  = 1
	ServerModeHttps   = "HTTPS"
	ServerModeIdHttps = 2
)
View Source
const (
	ErrFileExtensionIsUnsupported = "unsupported file extension: %v"
)
View Source
const (
	IndexHtmlPageFileName = "index.html"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedFile

type CachedFile struct {
	Name     string
	Contents []byte
	MimeType string
}

func NewCachedFile

func NewCachedFile(
	fileName string,
	contents []byte,
) (cf *CachedFile, err error)

type Settings

type Settings struct {
	// Path to the File with these Settings.
	File string

	// Server's Host Name.
	ServerHost string

	// Server's Listen Port.
	ServerPort uint16

	// ServerMode is an HTTP mode selector.
	// Possible values are: HTTP and HTTPS.
	ServerModeStr string
	ServerModeId  byte

	// Server's Certificate and Key.
	CertFile string
	KeyFile  string

	// HttpCacheControlMaxAge is time in seconds for which this server's
	// response is fresh (valid). After this period clients will be refreshing
	// the stale content by re-requesting it from the server.
	HttpCacheControlMaxAge uint

	// Allowed Origin for cross-origin requests (CORS).
	AllowedOriginForCORS string

	// Names of files to be cached as pages.
	CachedPageFileNames []string
}

Settings is Server's settings.

func NewSettingsFromFile

func NewSettingsFromFile(filePath string) (stn *Settings, err error)

func (*Settings) Check

func (stn *Settings) Check() (err error)

Jump to

Keyboard shortcuts

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