Set gitlab_token column, and use ioutil for r.Body

This commit is contained in:
Nurahmadie 2014-03-30 21:32:20 +00:00
parent e2a45df3b8
commit c295776b87
2 changed files with 7 additions and 6 deletions

View file

@ -25,7 +25,11 @@ func (r *rev20140328201430) Up(mg *MigrationDriver) error {
return err
}
_, err := mg.AddColumn("users", mg.T.String("gitlab_token"))
if _, err := mg.AddColumn("users", mg.T.String("gitlab_token")); err != nil {
return err
}
_, err := mg.Tx.Exec(`update users set gitlab_token=?`, "")
return err
}

View file

@ -3,6 +3,7 @@ package handler
import (
"database/sql"
"fmt"
"io/ioutil"
"net/http"
"time"
@ -140,11 +141,7 @@ func (g *GitlabHandler) newGitlabRepo(u *User, owner, name string) (*Repo, error
}
func (g *GitlabHandler) Hook(w http.ResponseWriter, r *http.Request) error {
var payload []byte
n, err := r.Body.Read(payload)
if n == 0 {
return fmt.Errorf("Request Empty: %q", err)
}
payload, _ := ioutil.ReadAll(r.Body)
parsed, err := gogitlab.ParseHook(payload)
if err != nil {
return err