-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVidispineShapeMessageHandler.go
More file actions
36 lines (31 loc) · 1018 Bytes
/
VidispineShapeMessageHandler.go
File metadata and controls
36 lines (31 loc) · 1018 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
30
31
32
33
34
35
36
package main
import (
"fmt"
"gitlab.com/codmill/customer-projects/guardian/pluto-vs-relay/sender"
"log"
"net/http"
"time"
)
type VidispineShapeMessageHandler struct {
ConnectionPool sender.AmqpConnectionPool
ChannelTimeout time.Duration
ExchangeName string
}
/**
receive the message from VS and pass it on
*/
func (h VidispineShapeMessageHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
notificationPtr, bodyContentPtr := GetNotificationDocument(w, req)
if notificationPtr == nil || bodyContentPtr == nil {
return //the error message has already been output
}
routingKey := fmt.Sprintf("vidispine.item.shape.%s", notificationPtr.GetAction())
log.Printf("DEBUG VidispineItemMessageHandler.ServeHTTP received message for %s", routingKey)
sendErr := h.ConnectionPool.Send(h.ExchangeName, routingKey, bodyContentPtr)
if sendErr == nil {
w.WriteHeader(200)
} else {
log.Print("ERROR VidispineItemMessageHandler.ServeHTTP could not send message at all!")
w.WriteHeader(500)
}
}