Set gitlab_token column, and use ioutil for r.Body
This commit is contained in:
parent
e2a45df3b8
commit
c295776b87
2 changed files with 7 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue