mirror of
https://github.com/elyby/chrly.git
synced 2024-11-26 16:51:59 +05:30
Добавлен функционал проверки существования скина для роута /cloaks
This commit is contained in:
parent
4bcd0495ed
commit
98b787fa99
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
||||
# Игнорим данные, т.к. они не нужны для внутреннего содержимого этого контейнера
|
||||
data
|
@ -1,6 +1,7 @@
|
||||
FROM golang:1.7
|
||||
|
||||
RUN mkdir -p /go/src/elyby/minecraft-skinsystem \
|
||||
/go/src/elyby/minecraft-skinsystem/data/capes \
|
||||
&& ln -s /go/src/elyby/minecraft-skinsystem /go/src/app
|
||||
|
||||
WORKDIR /go/src/app
|
||||
|
2
data/capes/.gitignore
vendored
Normal file
2
data/capes/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
@ -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) {
|
||||
|
@ -8,3 +8,5 @@ import (
|
||||
var RedisPool *pool.Pool
|
||||
|
||||
var RabbitMQChannel *amqp.Channel
|
||||
|
||||
var RootFolder string
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
"elyby/minecraft-skinsystem/lib/routes"
|
||||
"elyby/minecraft-skinsystem/lib/services"
|
||||
"elyby/minecraft-skinsystem/lib/worker"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
const redisString string = "redis:6379"
|
||||
@ -64,6 +65,9 @@ func main() {
|
||||
services.RedisPool = redisPool
|
||||
services.RabbitMQChannel = rabbitChannel
|
||||
|
||||
_, file, _, _ := runtime.Caller(0)
|
||||
services.RootFolder = filepath.Dir(file)
|
||||
|
||||
go func() {
|
||||
period := 5
|
||||
for {
|
||||
|
Loading…
Reference in New Issue
Block a user