mirror of
https://github.com/elyby/chrly.git
synced 2024-12-22 21:19:55 +05:30
Добавлен роут для загрузки рендера лица скина
This commit is contained in:
parent
0d6ca356d1
commit
e03832b4e8
31
lib/routes/Face.go
Normal file
31
lib/routes/Face.go
Normal file
@ -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"
|
||||
}
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user