Create debugSaveRequest from common debug code.
This commit is contained in:
parent
8e325b7c77
commit
3f2d1eeb42
2 changed files with 22 additions and 27 deletions
19
api/debug.go
Normal file
19
api/debug.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package api
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func debugSaveRequest(body []byte, err error, message string) {
|
||||
// TODO(eliribble): avoid using a single static filename and instead securely generate
|
||||
// this value
|
||||
log.Error().Err(err).Msg(message)
|
||||
output, err := os.OpenFile("/tmp/request.body", os.O_RDWR|os.O_CREATE, 0666)
|
||||
if err != nil {
|
||||
log.Info().Msg("Failed to open temp request.bady")
|
||||
}
|
||||
defer output.Close()
|
||||
output.Write(body)
|
||||
log.Info().Msg("Wrote request to /tmp/request.body")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue