From d9fbfe658a271f798e1f818d45f8aac925f3f337 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Mon, 20 Apr 2020 15:40:20 +0300 Subject: [PATCH] Cleanup TODO items --- db/factory.go | 25 ------------------------- di/handlers.go | 3 +++ di/mojang_textures.go | 1 - http/skinsystem.go | 12 ++---------- 4 files changed, 5 insertions(+), 36 deletions(-) diff --git a/db/factory.go b/db/factory.go index a8a27a6..7baf993 100644 --- a/db/factory.go +++ b/db/factory.go @@ -1,37 +1,12 @@ package db import ( - "github.com/spf13/viper" - "github.com/elyby/chrly/http" "github.com/elyby/chrly/mojangtextures" ) -type StorageFactory struct { - Config *viper.Viper -} - type RepositoriesCreator interface { CreateSkinsRepository() (http.SkinsRepository, error) CreateCapesRepository() (http.CapesRepository, error) CreateMojangUuidsRepository() (mojangtextures.UuidsStorage, error) } - -// TODO: redundant -func (factory *StorageFactory) CreateFactory(backend string) RepositoriesCreator { - switch backend { - case "redis": - return &RedisFactory{ - Host: factory.Config.GetString("storage.redis.host"), - Port: factory.Config.GetInt("storage.redis.port"), - PoolSize: factory.Config.GetInt("storage.redis.poolSize"), - } - case "filesystem": - return &FilesystemFactory{ - BasePath: factory.Config.GetString("storage.filesystem.basePath"), - CapesDirName: factory.Config.GetString("storage.filesystem.capesDirName"), - } - } - - return nil -} diff --git a/di/handlers.go b/di/handlers.go index 4a2d657..0fb5fdf 100644 --- a/di/handlers.go +++ b/di/handlers.go @@ -100,6 +100,9 @@ func newSkinsystemHandler( capesRepository CapesRepository, mojangTexturesProvider MojangTexturesProvider, ) *mux.Router { + config.SetDefault("textures.extra_param_name", "chrly") + config.SetDefault("textures.extra_param_value", "how do you tame a horse in Minecraft?") + return (&Skinsystem{ Emitter: emitter, SkinsRepo: skinsRepository, diff --git a/di/mojang_textures.go b/di/mojang_textures.go index afd0851..dee1bec 100644 --- a/di/mojang_textures.go +++ b/di/mojang_textures.go @@ -78,7 +78,6 @@ func newMojangTexturesBatchUUIDsProvider( config *viper.Viper, emitter mojangtextures.Emitter, ) (*mojangtextures.BatchUuidsProvider, error) { - // TODO: remove usage of di.WithName() when https://github.com/goava/di/issues/11 will be resolved if err := container.Provide(func(emitter es.Subscriber, config *viper.Viper) *namedHealthChecker { config.SetDefault("healthcheck.mojang_batch_uuids_provider_cool_down_duration", time.Minute) diff --git a/http/skinsystem.go b/http/skinsystem.go index 3a065d4..52c36e3 100644 --- a/http/skinsystem.go +++ b/http/skinsystem.go @@ -208,8 +208,8 @@ func (ctx *Skinsystem) signedTexturesHandler(response http.ResponseWriter, reque } responseData.Props = append(responseData.Props, &mojang.Property{ - Name: getStringOrDefault(ctx.TexturesExtraParamName, "chrly"), // TODO: extract to the default param value - Value: getStringOrDefault(ctx.TexturesExtraParamValue, "how do you tame a horse in Minecraft?"), + Name: ctx.TexturesExtraParamName, + Value: ctx.TexturesExtraParamValue, }) responseJson, _ := json.Marshal(responseData) @@ -220,11 +220,3 @@ func (ctx *Skinsystem) signedTexturesHandler(response http.ResponseWriter, reque func parseUsername(username string) string { return strings.TrimSuffix(username, ".png") } - -func getStringOrDefault(value string, def string) string { - if value != "" { - return value - } - - return def -}