mirror of
https://github.com/elyby/chrly.git
synced 2024-12-22 21:19:55 +05:30
Корректировка под более-менее финальную версию протокола
This commit is contained in:
parent
c2d0cb93cb
commit
64bf7deb79
@ -10,7 +10,7 @@ import (
|
||||
|
||||
type SkinItem struct {
|
||||
UserId int `json:"userId"`
|
||||
Nickname string `json:"nickname"`
|
||||
Username string `json:"username"`
|
||||
SkinId int `json:"skinId"`
|
||||
Url string `json:"url"`
|
||||
Is1_8 bool `json:"is1_8"`
|
||||
@ -20,7 +20,7 @@ type SkinItem struct {
|
||||
|
||||
func (s *SkinItem) Save() {
|
||||
str, _ := json.Marshal(s)
|
||||
services.Redis.Cmd("SET", tools.BuildKey(s.Nickname), str)
|
||||
services.Redis.Cmd("SET", tools.BuildKey(s.Username), str)
|
||||
}
|
||||
|
||||
func FindRecord(username string) (SkinItem, error) {
|
||||
|
@ -2,7 +2,6 @@ package routes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"strconv"
|
||||
|
||||
"elyby/minecraft-skinsystem/lib/data"
|
||||
@ -17,7 +16,7 @@ func SetSkin(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
skin := new(data.SkinItem)
|
||||
skin.Nickname = strings.ToLower(r.PostFormValue("nickname"))
|
||||
skin.Username = r.PostFormValue("username")
|
||||
skin.UserId, _ = strconv.Atoi(r.PostFormValue("userId"))
|
||||
skin.SkinId, _ = strconv.Atoi(r.PostFormValue("skinId"))
|
||||
skin.Hash = r.PostFormValue("hash")
|
||||
|
@ -20,7 +20,7 @@ func Skin(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, rec.Url, 301);
|
||||
http.Redirect(w, r, tools.BuildElyUrl(rec.Url), 301);
|
||||
}
|
||||
|
||||
func SkinGET(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -23,7 +23,7 @@ func Textures(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
textures := data.TexturesResponse{
|
||||
Skin: &data.Skin{
|
||||
Url: rec.Url,
|
||||
Url: tools.BuildElyUrl(rec.Url),
|
||||
Hash: rec.Hash,
|
||||
},
|
||||
}
|
||||
|
@ -29,7 +29,12 @@ func BuildKey(username string) string {
|
||||
return "username:" + strings.ToLower(username)
|
||||
}
|
||||
|
||||
func BuildElyUrl(route string) string {
|
||||
return "http://ely.by" + route
|
||||
}
|
||||
|
||||
func getCurrentHour() int64 {
|
||||
n := time.Now()
|
||||
return time.Date(n.Year(), n.Month(), n.Day(), n.Hour(), 0, 0, 0, time.UTC).Unix()
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,6 @@ func main() {
|
||||
// 404
|
||||
router.NotFoundHandler = http.HandlerFunc(routes.NotFound)
|
||||
|
||||
// TODO: убрать этого, т.к. он стар
|
||||
router.HandleFunc("/system/setSkin", routes.SetSkin).Methods("POST")
|
||||
|
||||
apiRouter := router.PathPrefix("/api").Subrouter()
|
||||
apiRouter.HandleFunc("/user/{username}/skin", routes.SetSkin).Methods("POST")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user