MCPcopy Create free account
hub / github.com/chanify/chanify / bindBodyJSON

Method bindBodyJSON

core/utils.go:28–41  ·  view source on GitHub ↗
(ctx *gin.Context, obj interface{})

Source from the content-addressed store, hash-verified

26)
27
28func (c *Core) bindBodyJSON(ctx *gin.Context, obj interface{}) error {
29 body, err := io.ReadAll(ctx.Request.Body)
30 if err != nil {
31 return err
32 }
33 ctx.Set(gin.BodyBytesKey, body)
34 if strings.HasPrefix(ctx.ContentType(), "application/x-chsec-json") {
35 body, err = c.logic.Decrypt(body)
36 if err != nil {
37 return err
38 }
39 }
40 return json.Unmarshal(body, obj)
41}
42
43func verifyUser(ctx *gin.Context, key string) bool {
44 sign, err := crypto.Base64Encode.DecodeString(ctx.GetHeader("CHUserSign"))

Callers 4

handleUpdatePushTokenMethod · 0.95
handleBindUserMethod · 0.95
handleUnbindUserMethod · 0.95
TestBindBodyJsonFunction · 0.80

Calls 1

DecryptMethod · 0.45

Tested by 1

TestBindBodyJsonFunction · 0.64