Реорганизация пакета daemon в http.

Упразднён пакет utils.
Удалён обработчик minecraft.php (legacy с самого-самого начала Ely.by)
Добавлены тесты для всех api-запросов.
This commit is contained in:
ErickSkrauch
2017-08-20 01:22:42 +03:00
parent ec461efe34
commit 04714543b8
29 changed files with 1170 additions and 381 deletions

View File

@@ -5,8 +5,8 @@ import (
"path"
"strings"
"elyby/minecraft-skinsystem/model"
"elyby/minecraft-skinsystem/interfaces"
"elyby/minecraft-skinsystem/model"
)
type FilesystemFactory struct {
@@ -42,19 +42,18 @@ type filesStorage struct {
path string
}
func (repository *filesStorage) FindByUsername(username string) (model.Cape, error) {
var record model.Cape
func (repository *filesStorage) FindByUsername(username string) (*model.Cape, error) {
if username == "" {
return record, &CapeNotFoundError{username}
return nil, &CapeNotFoundError{username}
}
capePath := path.Join(repository.path, strings.ToLower(username) + ".png")
file, err := os.Open(capePath)
if err != nil {
return record, &CapeNotFoundError{username}
return nil, &CapeNotFoundError{username}
}
record.File = file
return record, nil
return &model.Cape{
File: file,
}, nil
}