mirror of
https://github.com/elyby/chrly.git
synced 2025-05-31 14:11:51 +05:30
Добавлен функционал проверки существования скина для роута /cloaks
This commit is contained in:
@@ -1,18 +1,28 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"os"
|
||||
"io"
|
||||
"log"
|
||||
"strings"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"elyby/minecraft-skinsystem/lib/tools"
|
||||
"elyby/minecraft-skinsystem/lib/services"
|
||||
)
|
||||
|
||||
func Cape(w http.ResponseWriter, r *http.Request) {
|
||||
username := tools.ParseUsername(mux.Vars(r)["username"])
|
||||
func Cape(response http.ResponseWriter, request *http.Request) {
|
||||
username := tools.ParseUsername(mux.Vars(request)["username"])
|
||||
log.Println("request cape for username " + username)
|
||||
http.Redirect(w, r, "http://skins.minecraft.net/MinecraftCloaks/" + username + ".png", 301)
|
||||
file, err := os.Open(services.RootFolder + "/data/capes/" + strings.ToLower(username) + ".png")
|
||||
if (err != nil) {
|
||||
http.Redirect(response, request, "http://skins.minecraft.net/MinecraftCloaks/" + username + ".png", 301)
|
||||
}
|
||||
|
||||
request.Header.Set("Content-Type", "image/png")
|
||||
io.Copy(response, file)
|
||||
}
|
||||
|
||||
func CapeGET(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user