config

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONFIG_FILE_NAME = "gte.config.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host         string            `json:"host"`
	Port         int               `json:"port"`
	Routes       []Route           `json:"routes"`
	NotFoundPage string            `json:"notFoundPage"`
	BlackList    []string          `json:"blackList"`
	ApiServer    string            `json:"apiServer"` //API server, e.g. "http://localhost:12300"
	Envs         map[string]Config `json:"envs"`      //customized environments
	Lang         struct {
		Dir        string `json:"dir"`        //language resources location
		Default    string `json:"default"`    //default language, e.g. 'zh-CN'
		KeyAsValue bool   `json:"keyAsValue"` //return key as value when request of default language comes
	} `json:"lang"` //language setup

	Root              string                       `json:"-"` //root directory of your project
	Env               string                       `json:"-"`
	InternalBlackList []string                     `json:"-"`
	Strs              map[string]map[string]string `json:"-"`
}

func LoadConfig

func LoadConfig(env, root string, port int) (Config, error)

type Route

type Route struct {
	Path string `json:"path"`
	To   string `json:"to"`
}

func (*Route) ParamPrefix

func (r *Route) ParamPrefix() (string, bool)

func (*Route) Params

func (r *Route) Params(uri string) map[string]string

Jump to

Keyboard shortcuts

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