mirror of
https://github.com/elyby/chrly.git
synced 2024-12-02 11:40:56 +05:30
30 lines
611 B
Go
30 lines
611 B
Go
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"])
|
|
rec, err := data.FindSkinByUsername(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 "/minecraft/skin_buffer/faces/" + hash + ".png"
|
|
}
|