mirror of
https://github.com/elyby/chrly.git
synced 2024-12-24 14:09:56 +05:30
c4cd95cddc
Добавлен роут для смены скина
25 lines
579 B
Go
25 lines
579 B
Go
package routes
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
"elyby/minecraft-skinsystem/lib/tools"
|
|
"elyby/minecraft-skinsystem/lib/data"
|
|
)
|
|
|
|
func Skin(w http.ResponseWriter, r *http.Request) {
|
|
username := tools.ParseUsername(mux.Vars(r)["username"])
|
|
log.Println("request skin for username " + username);
|
|
rec, err := data.FindRecord(username)
|
|
if (err != nil) {
|
|
http.Redirect(w, r, "http://skins.minecraft.net/MinecraftSkins/" + username + ".png", 301)
|
|
log.Println("Cannot get skin for username " + username)
|
|
return
|
|
}
|
|
|
|
http.Redirect(w, r, rec.Url, 301);
|
|
}
|