mirror of
https://github.com/elyby/chrly.git
synced 2025-05-31 14:11:51 +05:30
Добавлено логгирование метрик для системы скинов
This commit is contained in:
@@ -2,18 +2,21 @@ package routes
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"elyby/minecraft-skinsystem/lib/tools"
|
||||
"elyby/minecraft-skinsystem/lib/data"
|
||||
"elyby/minecraft-skinsystem/lib/services"
|
||||
)
|
||||
|
||||
func Cape(response http.ResponseWriter, request *http.Request) {
|
||||
if (mux.Vars(request)["converted"] == "") {
|
||||
services.Logger.IncCounter("capes.request", 1)
|
||||
}
|
||||
|
||||
username := tools.ParseUsername(mux.Vars(request)["username"])
|
||||
log.Println("request cape for username " + username)
|
||||
rec, err := data.FindCapeByUsername(username)
|
||||
if (err != nil) {
|
||||
http.Redirect(response, request, "http://skins.minecraft.net/MinecraftCloaks/" + username + ".png", 301)
|
||||
@@ -24,6 +27,7 @@ func Cape(response http.ResponseWriter, request *http.Request) {
|
||||
}
|
||||
|
||||
func CapeGET(w http.ResponseWriter, r *http.Request) {
|
||||
services.Logger.IncCounter("capes.get-request", 1)
|
||||
username := r.URL.Query().Get("name")
|
||||
if username == "" {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
@@ -31,5 +35,6 @@ func CapeGET(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
mux.Vars(r)["username"] = username
|
||||
mux.Vars(r)["converted"] = "1"
|
||||
Cape(w, r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user