app

package
v0.0.0-...-0bd6e25 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package app is the collection of the methods to create or load the app configuration from the engine. The app is the collection of the services.

Depends on the engine. Managed by the handler.

Index

Constants

View Source
const (
	EnvConfigName = "CONFIG_NAME"
	EnvConfigPath = "CONFIG_PATH"
)

Variables

This section is empty.

Functions

func MakeConfigDir

func MakeConfigDir(filePath string) error

MakeConfigDir converts fileParams to the full file path. if the configuration file is stored in the nested directory, then those directories are created.

func Read

func Read(filePath string, data interface{}) error

Read yaml file

func ReadFileParameters

func ReadFileParameters(configEngine *engine.Dev) (string, bool, error)

The ReadFileParameters returns the file path. First it reads from a flag, then from environment variable. Lastly, read the default file.

func Write

func Write(filePath string, data interface{}) error

Write the service as the yaml on the given path. If the path doesn't contain the file extension, it will through an error

Types

type App

type App struct {
	Services    []*service.Service    `json:"services" yaml:"services"`
	ProxyChains []*service.ProxyChain `json:"proxy_chains" yaml:"proxy_chains"`
	// contains filtered or unexported fields
}

App is the configuration of the entire application. Consists the supported services and proxy chains.

Fields

  • Services in the application
  • ProxyChains list of proxies that targets to the services

func New

func New() *App

New App configuration. If possible, it loads the configuration.

Loading order: - create a default app config - if app.yml exists in the root, then load it. - if, environment variable exists, then load it. - if, a flag exists, then load it.

func (*App) IdExist

func (a *App) IdExist(id string) bool

IdExist checks is the id unique within the application

func (*App) RegisterId

func (a *App) RegisterId() error

RegisterId sets all ids of the all services and handlers. If there are duplicate id, then throw an error with detail information.

func (*App) Service

func (a *App) Service(id string) *service.Service

Service by id returned from the app configuration. If not found, return nil

func (*App) ServiceByUrl

func (a *App) ServiceByUrl(url string) *service.Service

ServiceByUrl returns the first service of an url type.

func (*App) SetEmptyFields

func (a *App) SetEmptyFields()

SetEmptyFields sets empty value for nil fields. If the developer crated App directly, some fields might be nil

func (*App) SetId

func (a *App) SetId(id string) bool

SetId sets the id in the id list. Returns true if id exists.

func (*App) SetService

func (a *App) SetService(s *service.Service) error

SetService sets a new service into the configuration. After setting, the app will write it to the file.

Jump to

Keyboard shortcuts

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