From e03832b4e8f2596b4ad93179e4371f1421341f95 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Wed, 21 Sep 2016 20:52:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=80=D0=BE=D1=83=D1=82=20=D0=B4=D0=BB=D1=8F=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8=20=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=B4=D0=B5=D1=80=D0=B0=20=D0=BB=D0=B8=D1=86=D0=B0=20=D1=81?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/Face.go | 31 +++++++++++++++++++++++++++++++ minecraft-skinsystem.go | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 lib/routes/Face.go diff --git a/lib/routes/Face.go b/lib/routes/Face.go new file mode 100644 index 0000000..7b99996 --- /dev/null +++ b/lib/routes/Face.go @@ -0,0 +1,31 @@ +package routes + +import ( + "log" + "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"]) + log.Println("request skin for username " + username); + rec, err := data.FindByUsername(username) + 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 { + return "/minecfaft/skin_buffer/faces/" + hash + ".png" +} diff --git a/minecraft-skinsystem.go b/minecraft-skinsystem.go index 513aa30..1f99e2a 100644 --- a/minecraft-skinsystem.go +++ b/minecraft-skinsystem.go @@ -49,6 +49,8 @@ func main() { router.HandleFunc("/skins/{username}", routes.Skin).Methods("GET").Name("skins") router.HandleFunc("/cloaks/{username}", routes.Cape).Methods("GET").Name("cloaks") router.HandleFunc("/textures/{username}", routes.Textures).Methods("GET").Name("textures") + router.HandleFunc("/skins/{username}/face", routes.Face).Methods("GET").Name("faces") + router.HandleFunc("/skins/{username}/face.png", routes.Face).Methods("GET").Name("faces") // Legacy router.HandleFunc("/minecraft.php", routes.MinecraftPHP).Methods("GET") router.HandleFunc("/skins/", routes.SkinGET).Methods("GET")