mirror of
https://github.com/elyby/chrly.git
synced 2024-12-05 04:59:00 +05:30
41 lines
896 B
Go
41 lines
896 B
Go
package routes
|
|
|
|
import (
|
|
"strings"
|
|
"net/http"
|
|
"encoding/json"
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
"elyby/minecraft-skinsystem/lib/data"
|
|
"elyby/minecraft-skinsystem/lib/tools"
|
|
"elyby/minecraft-skinsystem/lib/services"
|
|
)
|
|
|
|
func SignedTextures(w http.ResponseWriter, r *http.Request) {
|
|
services.Logger.IncCounter("signed_textures.request", 1)
|
|
username := tools.ParseUsername(mux.Vars(r)["username"])
|
|
|
|
rec, err := data.FindSkinByUsername(username)
|
|
if (err != nil || rec.SkinId == 0) {
|
|
w.WriteHeader(http.StatusNoContent)
|
|
return
|
|
}
|
|
|
|
responseData:= data.SignedTexturesResponse{
|
|
Id: strings.Replace(rec.Uuid, "-", "", -1),
|
|
Name: rec.Username,
|
|
Props: []data.Property{
|
|
{
|
|
Name: "textures",
|
|
Signature: rec.MojangSignature,
|
|
Value: rec.MojangTextures,
|
|
},
|
|
},
|
|
}
|
|
|
|
response,_ := json.Marshal(responseData)
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Write(response)
|
|
}
|