mirror of
https://github.com/elyby/chrly.git
synced 2024-12-24 14:09:56 +05:30
27 lines
443 B
Go
27 lines
443 B
Go
|
package files
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"path"
|
||
|
"strings"
|
||
|
|
||
|
"elyby/minecraft-skinsystem/model"
|
||
|
)
|
||
|
|
||
|
type filesDb struct {
|
||
|
path string
|
||
|
}
|
||
|
|
||
|
func (repository *filesDb) FindByUsername(username string) (model.Cape, error) {
|
||
|
var record model.Cape
|
||
|
capePath := path.Join(repository.path, strings.ToLower(username) + ".png")
|
||
|
file, err := os.Open(capePath)
|
||
|
if err != nil {
|
||
|
return record, CapeNotFound{username}
|
||
|
}
|
||
|
|
||
|
record.File = file
|
||
|
|
||
|
return record, nil
|
||
|
}
|