Merge branch 'develop' into statsd

This commit is contained in:
ErickSkrauch 2017-03-25 15:56:07 +03:00
commit 445bd18fbc
3 changed files with 33 additions and 32 deletions

33
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,33 @@
image: docker:latest
stages:
- build
- push
before_script:
- docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by
variables:
CONTAINER_IMAGE: registry.ely.by/elyby/skinsystem
build:
stage: build
script:
- export IMAGE_NAME="$CONTAINER_IMAGE:dev"
- docker build --pull -t $IMAGE_NAME .
- docker push $IMAGE_NAME
only:
- develop
push_tags:
stage: push
variables:
GIT_STRATEGY: none
script:
- export IMAGE_NAME="$CONTAINER_IMAGE:$CI_BUILD_TAG"
- docker tag $CONTAINER_IMAGE:dev $CONTAINER_IMAGE:latest
- docker tag $CONTAINER_IMAGE:latest $IMAGE_NAME
- docker push $IMAGE_NAME
- docker push $CONTAINER_IMAGE:latest
only:
- tags

View File

@ -1,29 +0,0 @@
package routes
import (
"net/http"
"strconv"
"elyby/minecraft-skinsystem/lib/data"
)
func SetSkin(w http.ResponseWriter, r *http.Request) {
key := r.Header.Get("X-Ely-key")
if key != "43fd2ce61b3f5704dfd729c1f2d6ffdb" {
w.WriteHeader(http.StatusForbidden)
w.Write([]byte("Nice try"))
return
}
skin := new(data.SkinItem)
skin.Username = r.PostFormValue("username")
skin.UserId, _ = strconv.Atoi(r.PostFormValue("userId"))
skin.SkinId, _ = strconv.Atoi(r.PostFormValue("skinId"))
skin.Hash = r.PostFormValue("hash")
skin.Is1_8, _ = strconv.ParseBool(r.PostFormValue("is1_8"))
skin.IsSlim, _ = strconv.ParseBool(r.PostFormValue("isSlim"))
skin.Url = r.PostFormValue("url")
skin.Save()
w.Write([]byte("OK"))
}

View File

@ -94,9 +94,6 @@ func main() {
// 404
router.NotFoundHandler = http.HandlerFunc(routes.NotFound)
apiRouter := router.PathPrefix("/api").Subrouter()
apiRouter.HandleFunc("/user/{username}/skin", routes.SetSkin).Methods("POST")
services.Router = router
services.RedisPool = redisPool
services.RabbitMQChannel = rabbitChannel