mirror of
https://github.com/elyby/chrly.git
synced 2024-12-24 14:09:56 +05:30
04714543b8
Упразднён пакет utils. Удалён обработчик minecraft.php (legacy с самого-самого начала Ely.by) Добавлены тесты для всех api-запросов.
28 lines
607 B
Go
28 lines
607 B
Go
package http
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gorilla/mux"
|
|
)
|
|
|
|
const defaultHash = "default"
|
|
|
|
func (cfg *Config) Face(response http.ResponseWriter, request *http.Request) {
|
|
cfg.Logger.IncCounter("faces.request", 1)
|
|
username := parseUsername(mux.Vars(request)["username"])
|
|
rec, err := cfg.SkinsRepo.FindByUsername(username)
|
|
var hash string
|
|
if err != nil || rec.SkinId == 0 {
|
|
hash = defaultHash
|
|
} else {
|
|
hash = rec.Hash
|
|
}
|
|
|
|
http.Redirect(response, request, buildElyUrl(buildFaceUrl(hash)), 301)
|
|
}
|
|
|
|
func buildFaceUrl(hash string) string {
|
|
return "/minecraft/skin_buffer/faces/" + hash + ".png"
|
|
}
|