mirror of
https://github.com/elyby/chrly.git
synced 2025-03-12 02:49:26 +05:30
Добавлена установка значения GOMAXPROCS
Сервис роутера вынесен в глобальные
This commit is contained in:
parent
3d65529d2e
commit
2b8266b224
@ -2,6 +2,9 @@ package services
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mediocregopher/radix.v2/redis"
|
"github.com/mediocregopher/radix.v2/redis"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Redis *redis.Client
|
var Redis *redis.Client
|
||||||
|
|
||||||
|
var Router *mux.Router
|
||||||
|
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"runtime"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
@ -11,23 +12,26 @@ import (
|
|||||||
"elyby/minecraft-skinsystem/lib/services"
|
"elyby/minecraft-skinsystem/lib/services"
|
||||||
)
|
)
|
||||||
|
|
||||||
var client, redisErr = redis.Dial("tcp", "redis:6379")
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
||||||
|
client, redisErr := redis.Dial("tcp", "redis:6379")
|
||||||
if redisErr != nil {
|
if redisErr != nil {
|
||||||
log.Fatal("Redis unavailable")
|
log.Fatal("Redis unavailable")
|
||||||
}
|
}
|
||||||
|
|
||||||
services.Redis = client
|
|
||||||
|
|
||||||
router := mux.NewRouter().StrictSlash(true)
|
router := mux.NewRouter().StrictSlash(true)
|
||||||
router.HandleFunc("/", routes.NotFound)
|
router.HandleFunc("/", routes.NotFound)
|
||||||
router.HandleFunc("/skins/{username}", routes.Skin).Methods("GET")
|
router.HandleFunc("/skins/{username}", routes.Skin).Methods("GET").Name("skins")
|
||||||
router.HandleFunc("/textures/{username}", routes.Textures).Methods("GET")
|
router.HandleFunc("/textures/{username}", routes.Textures).Methods("GET").Name("textures")
|
||||||
router.HandleFunc("/system/setSkin", routes.SetSkin).Methods("POST") // TODO: убрать этого, т.к. он стар
|
// TODO: убрать этого, т.к. он стар
|
||||||
|
router.HandleFunc("/system/setSkin", routes.SetSkin).Methods("POST")
|
||||||
|
|
||||||
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")
|
||||||
|
|
||||||
|
services.Redis = client
|
||||||
|
services.Router = router
|
||||||
|
|
||||||
log.Fatal(http.ListenAndServe(":80", router))
|
log.Fatal(http.ListenAndServe(":80", router))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user