mirror of
https://github.com/elyby/chrly.git
synced 2024-11-13 00:35:58 +05:30
Cleanup TODO items
This commit is contained in:
parent
0be85b356b
commit
d9fbfe658a
@ -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
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user