mirror of
https://github.com/elyby/chrly.git
synced 2024-11-27 01:01:59 +05:30
Добавлены обработчики для Legacy запросов
This commit is contained in:
parent
e3f744ed10
commit
4da7a566f7
25
lib/routes/Cape.go
Normal file
25
lib/routes/Cape.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package routes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
|
||||||
|
"elyby/minecraft-skinsystem/lib/tools"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Cape(w http.ResponseWriter, r *http.Request) {
|
||||||
|
username := tools.ParseUsername(mux.Vars(r)["username"])
|
||||||
|
http.Redirect(w, r, "http://skins.minecraft.net/MinecraftCloaks/" + username + ".png", 301)
|
||||||
|
}
|
||||||
|
|
||||||
|
func CapeGET(w http.ResponseWriter, r *http.Request) {
|
||||||
|
username := r.URL.Query().Get("name")
|
||||||
|
if username == "" {
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mux.Vars(r)["username"] = username
|
||||||
|
Cape(w, r)
|
||||||
|
}
|
28
lib/routes/MinecraftPHP.go
Normal file
28
lib/routes/MinecraftPHP.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package routes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Метод-наследие от первой версии системы скинов.
|
||||||
|
// Всё ещё иногда используется
|
||||||
|
// Просто конвертируем данные и отправляем их в основной обработчик
|
||||||
|
func MinecraftPHP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
username := r.URL.Query().Get("name")
|
||||||
|
required := r.URL.Query().Get("type")
|
||||||
|
if username == "" || required == "" {
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mux.Vars(r)["username"] = username
|
||||||
|
switch required {
|
||||||
|
case "skin": Skin(w, r)
|
||||||
|
case "cloack": Cape(w, r)
|
||||||
|
default: {
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,3 +22,14 @@ func Skin(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
http.Redirect(w, r, rec.Url, 301);
|
http.Redirect(w, r, rec.Url, 301);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SkinGET(w http.ResponseWriter, r *http.Request) {
|
||||||
|
username := r.URL.Query().Get("name")
|
||||||
|
if username == "" {
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mux.Vars(r)["username"] = username
|
||||||
|
Skin(w, r)
|
||||||
|
}
|
||||||
|
@ -23,7 +23,13 @@ func main() {
|
|||||||
router := mux.NewRouter().StrictSlash(true)
|
router := mux.NewRouter().StrictSlash(true)
|
||||||
router.HandleFunc("/", routes.NotFound)
|
router.HandleFunc("/", routes.NotFound)
|
||||||
router.HandleFunc("/skins/{username}", routes.Skin).Methods("GET").Name("skins")
|
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("/textures/{username}", routes.Textures).Methods("GET").Name("textures")
|
||||||
|
// Legacy
|
||||||
|
router.HandleFunc("/minecraft.php", routes.MinecraftPHP).Methods("GET")
|
||||||
|
router.HandleFunc("/skins/", routes.SkinGET).Methods("GET")
|
||||||
|
router.HandleFunc("/cloaks/", routes.CapeGET).Methods("GET")
|
||||||
|
|
||||||
// TODO: убрать этого, т.к. он стар
|
// TODO: убрать этого, т.к. он стар
|
||||||
router.HandleFunc("/system/setSkin", routes.SetSkin).Methods("POST")
|
router.HandleFunc("/system/setSkin", routes.SetSkin).Methods("POST")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user