Server and client stubs.
Implemented HTTP server with configuration getting stub. Implemented CLI client with configuration getting stub.
This commit is contained in:
22
internal/configuration/config.go
Normal file
22
internal/configuration/config.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package configuration
|
||||
|
||||
import (
|
||||
// other
|
||||
"github.com/vrischmann/envconfig"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
HTTP struct {
|
||||
Listen string `envconfig:"default=127.0.0.1:62222"`
|
||||
WaitForSeconds int `envconfig:"default=10"`
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize loads configuration into memory.
|
||||
func (cf *config) Initialize() {
|
||||
log.Info().Msg("Loading configuration...")
|
||||
|
||||
_ = envconfig.Init(cf)
|
||||
|
||||
log.Info().Msgf("Configuration parsed: %+v", cf)
|
||||
}
|
25
internal/configuration/exported.go
Normal file
25
internal/configuration/exported.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package configuration
|
||||
|
||||
import (
|
||||
// local
|
||||
"sources.dev.pztrn.name/pztrn/giredore/internal/logger"
|
||||
|
||||
// other
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
var (
|
||||
log zerolog.Logger
|
||||
loggerInitialized bool
|
||||
|
||||
Cfg *config
|
||||
)
|
||||
|
||||
func Initialize() {
|
||||
log = logger.Logger.With().Str("type", "internal").Str("package", "configuration").Logger()
|
||||
loggerInitialized = true
|
||||
log.Info().Msg("Initializing...")
|
||||
|
||||
Cfg = &config{}
|
||||
Cfg.Initialize()
|
||||
}
|
Reference in New Issue
Block a user