forked from wish/eventmaster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.go
More file actions
29 lines (24 loc) · 710 Bytes
/
github.go
File metadata and controls
29 lines (24 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package eventmaster
import (
"encoding/json"
"net/http"
"github.com/julienschmidt/httprouter"
"github.com/pkg/errors"
"github.com/wish/eventmaster/jh"
)
func (s *Server) gitHubEvent(w http.ResponseWriter, r *http.Request, _ httprouter.Params) (interface{}, error) {
var info map[string]interface{}
if err := json.NewDecoder(r.Body).Decode(&info); err != nil {
return nil, jh.NewError(errors.Wrap(err, "json decode").Error(), http.StatusBadRequest)
}
id, err := s.store.AddEvent(&UnaddedEvent{
DC: "github",
Host: "github",
TopicName: "github",
Data: info,
})
if err != nil {
return nil, jh.Wrap(err, "add event")
}
return map[string]string{"event_id": id}, nil
}