mirror of
https://github.com/elyby/chrly.git
synced 2024-08-26 14:50:09 +05:30
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"
|
||
|
}
|