func (g GitlabHook) Handle(w http.ResponseWriter, r *http.Request, repo *Repo) (int, error) {
	if r.Method != "POST" {
		return http.StatusMethodNotAllowed, errors.New("the request had an invalid method")
	}

	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return http.StatusRequestTimeout, errors.New("could not read body from request")
	}

	err = g.handleToken(r, body, repo.Hook.Secret)
	if err != nil {
		return http.StatusBadRequest, err
	}

	event := r.Header.Get("X-Gitlab-Event")
	if event == "" {
		return http.StatusBadRequest, errors.New("the 'X-Gitlab-Event' header is required but was missing")
	}

	switch event {
	case "Push Hook":
		err = g.handlePush(body, repo)
		if !hookIgnored(err) && err != nil {
			return http.StatusBadRequest, err
		}

	// return 400 if we do not handle the event type.
	default:
		return http.StatusBadRequest, nil
	}

	return http.StatusOK, err
}
func (g GitlabHook) Handle(w http.ResponseWriter, r *http.Request, repo *Repo) (int, error) {
	if r.Method != "POST" {
		return http.StatusMethodNotAllowed, errors.New("the request had an invalid method")
	}

	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return http.StatusRequestTimeout, errors.New("could not read body from request")
	}

	err = g.handleToken(r, body, repo.Hook.Secret)
	if err != nil {
		return http.StatusBadRequest, err
	}

	event := r.Header.Get("X-Gitlab-Event")
	if event == "" {
		return http.StatusBadRequest, errors.New("the 'X-Gitlab-Event' header is required but was missing")
	}

	switch event {
	case "Push Hook":
		err = g.handlePush(body, repo)
		if !hookIgnored(err) && err != nil {
			return http.StatusBadRequest, err
		}

	
	default:
		return http.StatusBadRequest, nil
	}

	return http.StatusOK, err
}
func ( g GitlabHook ) Handle ( w http . ResponseWriter , r * http . Request , repo * Repo ) ( int , error ) { if r . Method != " " { return http . StatusMethodNotAllowed , errors . New ( " " ) } body , err := ioutil . ReadAll ( r . Body ) if err != nil { return http . StatusRequestTimeout , errors . New ( " " ) } err = g . handleToken ( r , body , repo . Hook . Secret ) if err != nil { return http . StatusBadRequest , err } event := r . Header . Get ( " " ) if event == " " { return http . StatusBadRequest , errors . New ( " " ) } switch event { case " " : err = g . handlePush ( body , repo ) if ! hookIgnored ( err ) && err != nil { return http . StatusBadRequest , err } // return 400 if we do not handle the event type. default : return http . StatusBadRequest , nil } return http . StatusOK , err }
// Handle satisfies hookHandler.
Handle satisfies hookHandler .