PLT-2058 Debugging incoming web hook content (#3150)

* PLT-2058 Debugging incoming web hook content

This change debugs contents of incoming webhooks using l4g.

The problem is that in order to debug the request body, it neads to be
read. And a Reader can only be read once. Hence, the body is only read
for Debugging if it is actually enabled. Furthermore, a new reader is
created from the content of the old reader in order for the rest of the
method to work as usual (with or without debugging).

The debug statement is wrapped in a closure, so that the content is
only copied if Debug is actually enabled.

It is not possible to return `(string, string)` from the closure to
`l4g.Debug()`. That is the reason the debugging is not done with `=%v`,
but the translations strings end with a space.

I tested the change with a `application/json` HTTP header as well as
`payload=`

The debug method is extracted into util/log.go in order to be re-usable
for debugging `io.Reader`

* Added a config flag to turn off incoming webhook debugging

Setting `EnableWebhookDebugging` to false in the `config.json` will
disable the printing of the content of incoming webhooks to the console

* Defaulting webhook debugging to true

* Added the setting of debugging incoming webhooks to the system console
Этот коммит содержится в:
Martin Schenck
2016-06-10 15:59:24 +02:00
коммит произвёл Joram Wilander
родитель 400bc8b46d
Коммит 24a2805456
7 изменённых файлов: 95 добавлений и 11 удалений

Просмотреть файл

@@ -83,12 +83,13 @@ type SqlSettings struct {
}
type LogSettings struct {
EnableConsole bool
ConsoleLevel string
EnableFile bool
FileLevel string
FileFormat string
FileLocation string
EnableConsole bool
ConsoleLevel string
EnableFile bool
FileLevel string
FileFormat string
FileLocation string
EnableWebhookDebugging bool
}
type FileSettings struct {