Cleanup TODO items

This commit is contained in:
ErickSkrauch 2020-04-20 15:40:20 +03:00
parent 0be85b356b
commit d9fbfe658a
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
4 changed files with 5 additions and 36 deletions

View File

@ -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
}

View File

@ -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,

View File

@ -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)

View File

@ -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
}