We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d3ae2f5 commit 9555233Copy full SHA for 9555233
routers/repo/package.go
@@ -8,7 +8,6 @@ import (
8
"encoding/base64"
9
"encoding/json"
10
"fmt"
11
- "io/ioutil"
12
"math/rand"
13
"net/http"
14
"regexp"
@@ -328,14 +327,12 @@ func DockerPluginEvent(ctx *context.Context) {
328
327
return
329
}
330
331
- body, err := ioutil.ReadAll(ctx.Req.Body)
332
- if err != nil {
333
- ctx.Error(http.StatusInternalServerError)
334
- log.Error("Failed to read event: %v", err)
335
- }
+ decoder := json.NewDecoder(ctx.Req.Body)
+ decoder.DisallowUnknownFields()
+
336
data := new(notifications.Envelope)
337
338
- err = json.Unmarshal(body, data)
+ err := decoder.Decode(data)
339
if err != nil {
340
ctx.Error(http.StatusInternalServerError)
341
log.Error("Failed to unmarshal event: %v", err)
0 commit comments