Home / Function/ ShouldBindBodyWith() — gin Function Reference

ShouldBindBodyWith() — gin Function Reference

Architecture documentation for the ShouldBindBodyWith() function in context.go from the gin codebase.

Function go CoreEngine Context calls 2 called by 5

Entity Profile

Dependency Diagram

graph TD
  2083ec18_369e_5122_2c7b_57a02900a1d8["ShouldBindBodyWith()"]
  a53c2d10_3615_5367_e9eb_114584d88b4d["ShouldBindBodyWithJSON()"]
  a53c2d10_3615_5367_e9eb_114584d88b4d -->|calls| 2083ec18_369e_5122_2c7b_57a02900a1d8
  631041a9_2974_5fc4_ad9a_a1f2259f236e["ShouldBindBodyWithXML()"]
  631041a9_2974_5fc4_ad9a_a1f2259f236e -->|calls| 2083ec18_369e_5122_2c7b_57a02900a1d8
  71ec5052_8bf7_9ae5_17d8_e83aed40ab17["ShouldBindBodyWithYAML()"]
  71ec5052_8bf7_9ae5_17d8_e83aed40ab17 -->|calls| 2083ec18_369e_5122_2c7b_57a02900a1d8
  7450c20c_0cab_f00f_3bc3_4c086816f68f["ShouldBindBodyWithTOML()"]
  7450c20c_0cab_f00f_3bc3_4c086816f68f -->|calls| 2083ec18_369e_5122_2c7b_57a02900a1d8
  34c73d46_0e82_d3a7_ed0f_886d6f28c881["ShouldBindBodyWithPlain()"]
  34c73d46_0e82_d3a7_ed0f_886d6f28c881 -->|calls| 2083ec18_369e_5122_2c7b_57a02900a1d8
  44988509_10d5_0b14_a382_53a2f1657cd7["Get()"]
  2083ec18_369e_5122_2c7b_57a02900a1d8 -->|calls| 44988509_10d5_0b14_a382_53a2f1657cd7
  6e9cb785_6d47_c8a3_8dee_973da7d71486["Set()"]
  2083ec18_369e_5122_2c7b_57a02900a1d8 -->|calls| 6e9cb785_6d47_c8a3_8dee_973da7d71486
  style 2083ec18_369e_5122_2c7b_57a02900a1d8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

context.go lines 928–943

func (c *Context) ShouldBindBodyWith(obj any, bb binding.BindingBody) (err error) {
	var body []byte
	if cb, ok := c.Get(BodyBytesKey); ok {
		if cbb, ok := cb.([]byte); ok {
			body = cbb
		}
	}
	if body == nil {
		body, err = io.ReadAll(c.Request.Body)
		if err != nil {
			return err
		}
		c.Set(BodyBytesKey, body)
	}
	return bb.BindBody(body, obj)
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does ShouldBindBodyWith() do?
ShouldBindBodyWith() is a function in the gin codebase.
What does ShouldBindBodyWith() call?
ShouldBindBodyWith() calls 2 function(s): Get, Set.
What calls ShouldBindBodyWith()?
ShouldBindBodyWith() is called by 5 function(s): ShouldBindBodyWithJSON, ShouldBindBodyWithPlain, ShouldBindBodyWithTOML, ShouldBindBodyWithXML, ShouldBindBodyWithYAML.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free