enable debug-only rabbitmq webhook hander
This commit is contained in:
parent
4c8eae5e7c
commit
937664dfba
@ -325,19 +325,24 @@ func parseRequestJSONOrg(reqType string, data []byte) (org *common.Organization,
|
||||
func main() {
|
||||
var listenAddr string
|
||||
var reqBearerToken string
|
||||
var doPublish bool
|
||||
|
||||
flag.BoolVar(&DebugMode, "debug", false, "enables debugging messages")
|
||||
flag.StringVar(&listenAddr, "listen", ListenAddrDef, "HTTP listen socket address for webhook events")
|
||||
flag.StringVar(&topicScope, "topic-domain", DefTopicDomain, "Default domain for RabbitMQ topics")
|
||||
flag.StringVar(&reqBearerToken, "token", "", "HTTP Bearer token to match")
|
||||
flag.BoolVar(&doPublish, "publish", true, "Publish to RabbitMQ. Disable for testing.")
|
||||
flag.Parse()
|
||||
|
||||
log.Println("Starting....")
|
||||
log.Printf(" * Debugging: %t\n", DebugMode)
|
||||
log.Printf(" * Listening: %s\n", listenAddr)
|
||||
log.Printf(" * Bearer token: %t\n", len(reqBearerToken) > 0)
|
||||
log.Printf(" * Publish to RabbitMQ: %t\n", doPublish)
|
||||
|
||||
if doPublish {
|
||||
connectToRabbitMQ()
|
||||
}
|
||||
|
||||
http.HandleFunc("POST /rabbitmq-forwarder", func(res http.ResponseWriter, req *http.Request) {
|
||||
if len(req.Header.Get("Content-Type")) == 0 ||
|
||||
@ -406,6 +411,7 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
if doPublish {
|
||||
err = PublishMessage(org.Username, reqType, extraAction, data)
|
||||
if err != nil {
|
||||
errorStr := fmt.Sprintf("hook (%s) processing error: %v\n", reqType, err)
|
||||
@ -418,6 +424,7 @@ func main() {
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
res.WriteHeader(http.StatusOK)
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user