MCPcopy Index your code
hub / github.com/dnote/dnote / New

Function New

pkg/server/config/config.go:86–102  ·  view source on GitHub ↗

New constructs and returns a new validated config. Empty string params will fall back to environment variables and defaults.

(p Params)

Source from the content-addressed store, hash-verified

84// New constructs and returns a new validated config.
85// Empty string params will fall back to environment variables and defaults.
86func New(p Params) (Config, error) {
87 c := Config{
88 Port: getOrEnv(p.Port, "PORT", "3001"),
89 BaseURL: getOrEnv(p.BaseURL, "BaseURL", "http://localhost:3001"),
90 DBPath: getOrEnv(p.DBPath, "DBPath", DefaultDBPath),
91 DisableRegistration: p.DisableRegistration || readBoolEnv("DisableRegistration"),
92 LogLevel: getOrEnv(p.LogLevel, "LOG_LEVEL", "info"),
93 AssetBaseURL: "/static",
94 HTTP500Page: assets.MustGetHTTP500ErrorPage(),
95 }
96
97 if err := validate(c); err != nil {
98 return Config{}, err
99 }
100
101 return c, nil
102}
103
104func validate(c Config) error {
105 if _, err := url.ParseRequestURI(c.BaseURL); err != nil {

Callers 2

createAppFunction · 0.92
startCmdFunction · 0.92

Calls 4

MustGetHTTP500ErrorPageFunction · 0.92
getOrEnvFunction · 0.85
readBoolEnvFunction · 0.85
validateFunction · 0.85

Tested by

no test coverage detected