mirror of
https://github.com/elyby/chrly.git
synced 2024-11-23 05:33:18 +05:30
Добавлена установка значения GOMAXPROCS
Сервис роутера вынесен в глобальные
This commit is contained in:
parent
3d65529d2e
commit
2b8266b224
@ -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
|
||||
|
@ -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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user