From 2b8266b2244e487c88b0c1bbeaec0122014492e8 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Thu, 7 Jul 2016 00:43:42 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20GOM?= =?UTF-8?q?AXPROCS=20=D0=A1=D0=B5=D1=80=D0=B2=D0=B8=D1=81=20=D1=80=D0=BE?= =?UTF-8?q?=D1=83=D1=82=D0=B5=D1=80=D0=B0=20=D0=B2=D1=8B=D0=BD=D0=B5=D1=81?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B2=20=D0=B3=D0=BB=D0=BE=D0=B1=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/services/services.go | 3 +++ minecraft-skinsystem.go | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/services/services.go b/lib/services/services.go index 6f0421b..d62f7ac 100644 --- a/lib/services/services.go +++ b/lib/services/services.go @@ -2,6 +2,9 @@ package services import ( "github.com/mediocregopher/radix.v2/redis" + "github.com/gorilla/mux" ) var Redis *redis.Client + +var Router *mux.Router diff --git a/minecraft-skinsystem.go b/minecraft-skinsystem.go index 64f03ca..c4ac5e0 100644 --- a/minecraft-skinsystem.go +++ b/minecraft-skinsystem.go @@ -2,6 +2,7 @@ package main import ( "log" + "runtime" "net/http" "github.com/gorilla/mux" @@ -11,23 +12,26 @@ import ( "elyby/minecraft-skinsystem/lib/services" ) -var client, redisErr = redis.Dial("tcp", "redis:6379") - func main() { + runtime.GOMAXPROCS(runtime.NumCPU()) + + client, redisErr := redis.Dial("tcp", "redis:6379") if redisErr != nil { log.Fatal("Redis unavailable") } - services.Redis = client - router := mux.NewRouter().StrictSlash(true) router.HandleFunc("/", routes.NotFound) - router.HandleFunc("/skins/{username}", routes.Skin).Methods("GET") - router.HandleFunc("/textures/{username}", routes.Textures).Methods("GET") - router.HandleFunc("/system/setSkin", routes.SetSkin).Methods("POST") // TODO: убрать этого, т.к. он стар + router.HandleFunc("/skins/{username}", routes.Skin).Methods("GET").Name("skins") + router.HandleFunc("/textures/{username}", routes.Textures).Methods("GET").Name("textures") + // TODO: убрать этого, т.к. он стар + router.HandleFunc("/system/setSkin", routes.SetSkin).Methods("POST") apiRouter := router.PathPrefix("/api").Subrouter() apiRouter.HandleFunc("/user/{username}/skin", routes.SetSkin).Methods("POST") + services.Redis = client + services.Router = router + log.Fatal(http.ListenAndServe(":80", router)) }