dvconfig

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package dvconfig provides configuration management for the http server MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com)

Package dvconfig manages configuration for http server MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com)

Index

Constants

This section is empty.

Variables

View Source
var CurrentDir string

CurrentDir is a current folder where the application started

View Source
var GlobalProperties map[string]string

GlobalProperties stores initial properties from environment and properties files

View Source
var LogConfig bool

LogConfig specifies whether message from package dvconfig must be logged

View Source
var MicroCoreConfig = "MicroCore.conf"

MicroCoreConfig is the config file name for http server, which can be customized by application

View Source
var MicroCoreNameSpace = "MICRO_CORE_CURRENT_NAMESPACE"

MicroCoreNameSpace is an environment variable name to specify the namespace, which is used for creation a folder inside the global work folder

View Source
var MicroCorePath = "MICRO_CORE_PATH"

MicroCorePath is an environment variable name to specify a folder where config and other info is stored

Functions

func FindAndReadConfigs

func FindAndReadConfigs(configName string, propertiesName string) string

FindAndReadConfigs finds the config by config name and properties file starting with the current folder

func ProcessBaseFolder

func ProcessBaseFolder(server *DvHostServer, hostServers []DvHostServer)

ProcessBaseFolder sets up the http server using information for all requested servers

func ProvideServerCommand

func ProvideServerCommand()

ProvideServerCommand registers the http server as server for command execution purposes

func ResetNamespaceFolder

func ResetNamespaceFolder()

ResetNamespaceFolder is used to change the current namespace

func SaveConfig

func SaveConfig(place string, cf *DvConfig)

SaveConfig saves the already-read config for the test purposes

func ServerStart

func ServerStart()

ServerStart starts http server, the config and properties are read from the current folder or by other options

func ServerStartByConfig

func ServerStartByConfig(cf *DvConfig)

ServerStartByConfig starts http server by the config provided as parameters

func SetApplicationName

func SetApplicationName(name string)

SetApplicationName allows to customize all config names, property file names and variable prefixes

Types

type DvConfig

type DvConfig struct {
	Namespace      string                       `json:"namespace"`
	Listen         string                       `json:"listen"`
	RootFolder     string                       `json:"rootFolder"`
	LogLevel       string                       `json:"logLevel"`
	LogModules     string                       `json:"logModules"`
	Hosts          []dvcom.IpList               `json:"hosts"`
	HostServers    []DvHostServer               `json:"hostServers"`
	SystemInfo     string                       `json:"systemInfo"`
	Server         DvHostServer                 `json:"server"`
	Modules        map[string]map[string]string `json:"modules"`
	Hooks          map[string]map[string]string `json:"hooks"`
	Processors     map[string]map[string]string `json:"processors"`
	PostProcessors map[string]map[string]string `json:"postProcessors"`
	Providers      map[string]map[string]string `json:"providers"`
}

DvConfig is a full structure of the config for http server

func ReadConfig

func ReadConfig() *DvConfig

ReadConfig reads the config and properties by default names for http server

type DvHostServer

type DvHostServer struct {
	Hosts                         string                         `json:"hosts"`
	BaseFolder                    string                         `json:"baseFolder"`
	Actions                       []dvmeta.DvAction              `json:"actions"`
	Rewrites                      []DvRewrite                    `json:"rewrites"`
	ExtraServer                   string                         `json:"extraServer"`
	ExtraServerSettings           dvmeta.ServerSettings          `json:"extraServerSettings"`
	ServerRewrites                []DvRewrite                    `json:"serverRewrites"`
	ProxyName                     string                         `json:"proxyName"`
	CacheControl                  string                         `json:"cacheControl"`
	DirectoryIndex                string                         `json:"directoryIndex"`
	HeadersStatic                 map[string]string              `json:"headersStatic"`
	HeadersExtraServer            map[string]string              `json:"headersExtraServer"`
	HeadersStaticOptions          map[string]string              `json:"headersStaticOptions"`
	HeadersExtraServerOptions     map[string]string              `json:"headersExtraServerOptions"`
	AccessControlAllowOrigin      string                         `json:"accessControlAllowOrigin"`
	AccessControlAllowMethod      string                         `json:"accessControlAllowMethod"`
	AccessControlAllowHeaders     string                         `json:"accessControlAllowHeaders"`
	AccessControlMaxAge           string                         `json:"accessControlMaxAge"`
	AccessControlExposeHeaders    string                         `json:"accessControlExposeHeaders"`
	AccessControlAllowCredentials string                         `json:"accessControlAllowCredentials"`
	Modules                       []dvmodules.ModuleConfig       `json:"modules"`
	Processors                    []dvprocessors.ProcessorConfig `json:"processors"`
	PostProcessors                []dvprocessors.ProcessorConfig `json:"postProcessors"`
	Providers                     []dvproviders.ProviderConfig   `json:"providers"`
	HostHeader                    string                         `json:"hostHeader"`
}

DvHostServer collects all parameters for a specific host server

type DvRewrite

type DvRewrite struct {
	From      string `json:"from"`
	To        string `json:"to"`
	Condition string `json:"condition"`
	Options   string `json:"options"`
}

DvRewrite describes the url rewriting parameters

Jump to

Keyboard shortcuts

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