fxappsettings

package
v0.0.0-...-7f48f6c Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(func(lc fx.Lifecycle, cfg *Config) (AppSettings, error) {
		if cfg.LocalesPath == "" || cfg.RegionsPath == "" {
			return nil, errors.New("locales path or regions path is empty")
		}

		m := appsettings.New()
		lc.Append(fx.Hook{
			OnStart: func(ctx context.Context) error {
				if err := m.LoadLocales(ctx, cfg.LocalesPath); err != nil {
					return err
				}

				return m.LoadRegions(ctx, cfg.RegionsPath)
			},
		})

		return m, nil
	}),
)

Functions

This section is empty.

Types

type AppSettings

type AppSettings interface {
	GetCountries(onlyEnabled bool) []string
	GetRegionsByCountryCode(code string) []string
	ValidateRegionCode(code string) error
	ValidateCountryCode(code string) error
	GetLanguages(onlyEnabled bool) []string
	ValidateLanguageCode(code string) error
}

type Config

type Config struct {
	RegionsPath string `json:"regionsPath"`
	LocalesPath string `json:"localesPath"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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