mirror of
https://github.com/elyby/chrly.git
synced 2025-03-12 19:09:16 +05:30
Revert "Реализована страница 404 ошибки"
This reverts commit c2d0cb93cbf49c7409c763b773c5cf3e5cc072e5.
This commit is contained in:
parent
c03021403a
commit
22f80576bd
@ -31,8 +31,6 @@ func FindRecord(username string) (SkinItem, error) {
|
|||||||
if (decodeErr != nil) {
|
if (decodeErr != nil) {
|
||||||
log.Println("Cannot decode record data")
|
log.Println("Cannot decode record data")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
log.Println("Error on request user data")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return record, err
|
return record, err
|
||||||
|
@ -9,7 +9,7 @@ func NotFound(w http.ResponseWriter, r *http.Request) {
|
|||||||
json, _ := json.Marshal(map[string]string{
|
json, _ := json.Marshal(map[string]string{
|
||||||
"status": "404",
|
"status": "404",
|
||||||
"message": "Not Found",
|
"message": "Not Found",
|
||||||
"link": "http://docs.ely.by/skin-system.html",
|
"link": "http://docs.ely.by",
|
||||||
})
|
})
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
@ -13,17 +12,16 @@ import (
|
|||||||
"elyby/minecraft-skinsystem/lib/services"
|
"elyby/minecraft-skinsystem/lib/services"
|
||||||
)
|
)
|
||||||
|
|
||||||
const redisString string = "redis:6379"
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
||||||
client, redisErr := redis.Dial("tcp", redisString)
|
client, redisErr := redis.Dial("tcp", "redis:6379")
|
||||||
if redisErr != nil {
|
if redisErr != nil {
|
||||||
log.Fatal("Redis unavailable")
|
log.Fatal("Redis unavailable")
|
||||||
}
|
}
|
||||||
|
|
||||||
router := mux.NewRouter().StrictSlash(true)
|
router := mux.NewRouter().StrictSlash(true)
|
||||||
|
router.HandleFunc("/", routes.NotFound)
|
||||||
router.HandleFunc("/skins/{username}", routes.Skin).Methods("GET").Name("skins")
|
router.HandleFunc("/skins/{username}", routes.Skin).Methods("GET").Name("skins")
|
||||||
router.HandleFunc("/cloaks/{username}", routes.Cape).Methods("GET").Name("cloaks")
|
router.HandleFunc("/cloaks/{username}", routes.Cape).Methods("GET").Name("cloaks")
|
||||||
router.HandleFunc("/textures/{username}", routes.Textures).Methods("GET").Name("textures")
|
router.HandleFunc("/textures/{username}", routes.Textures).Methods("GET").Name("textures")
|
||||||
@ -31,8 +29,6 @@ func main() {
|
|||||||
router.HandleFunc("/minecraft.php", routes.MinecraftPHP).Methods("GET")
|
router.HandleFunc("/minecraft.php", routes.MinecraftPHP).Methods("GET")
|
||||||
router.HandleFunc("/skins/", routes.SkinGET).Methods("GET")
|
router.HandleFunc("/skins/", routes.SkinGET).Methods("GET")
|
||||||
router.HandleFunc("/cloaks/", routes.CapeGET).Methods("GET")
|
router.HandleFunc("/cloaks/", routes.CapeGET).Methods("GET")
|
||||||
// 404
|
|
||||||
router.NotFoundHandler = http.HandlerFunc(routes.NotFound)
|
|
||||||
|
|
||||||
apiRouter := router.PathPrefix("/api").Subrouter()
|
apiRouter := router.PathPrefix("/api").Subrouter()
|
||||||
apiRouter.HandleFunc("/user/{username}/skin", routes.SetSkin).Methods("POST")
|
apiRouter.HandleFunc("/user/{username}/skin", routes.SetSkin).Methods("POST")
|
||||||
@ -40,24 +36,5 @@ func main() {
|
|||||||
services.Redis = client
|
services.Redis = client
|
||||||
services.Router = router
|
services.Router = router
|
||||||
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
time.Sleep(5 * time.Second)
|
|
||||||
|
|
||||||
resp := services.Redis.Cmd("PING")
|
|
||||||
if (resp.Err != nil) {
|
|
||||||
log.Println("Redis not pinged. Try to reconnect")
|
|
||||||
newClient, redisErr := redis.Dial("tcp", redisString)
|
|
||||||
if (redisErr != nil) {
|
|
||||||
log.Println("Cannot reconnect to redis")
|
|
||||||
} else {
|
|
||||||
services.Redis = newClient
|
|
||||||
log.Println("Reconnected")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
log.Println("Started");
|
|
||||||
log.Fatal(http.ListenAndServe(":80", router))
|
log.Fatal(http.ListenAndServe(":80", router))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user