2016-09-21 20:52:28 +03:00
|
|
|
package routes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
|
|
|
|
"elyby/minecraft-skinsystem/lib/tools"
|
|
|
|
"elyby/minecraft-skinsystem/lib/data"
|
|
|
|
)
|
|
|
|
|
|
|
|
const defaultHash = "default"
|
|
|
|
|
|
|
|
func Face(w http.ResponseWriter, r *http.Request) {
|
|
|
|
username := tools.ParseUsername(mux.Vars(r)["username"])
|
2016-09-22 19:32:00 +03:00
|
|
|
rec, err := data.FindSkinByUsername(username)
|
2016-09-21 20:52:28 +03:00
|
|
|
var hash string
|
|
|
|
if (err != nil || rec.SkinId == 0) {
|
|
|
|
hash = defaultHash;
|
|
|
|
} else {
|
|
|
|
hash = rec.Hash
|
|
|
|
}
|
|
|
|
|
|
|
|
http.Redirect(w, r, tools.BuildElyUrl(buildFaceUrl(hash)), 301);
|
|
|
|
}
|
|
|
|
|
|
|
|
func buildFaceUrl(hash string) string {
|
2016-11-15 13:41:52 +03:00
|
|
|
return "/minecraft/skin_buffer/faces/" + hash + ".png"
|
2016-09-21 20:52:28 +03:00
|
|
|
}
|