Home / Function/ MustBindWith() — gin Function Reference

MustBindWith() — gin Function Reference

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

Function go CoreEngine Context calls 2 called by 8

Entity Profile

Dependency Diagram

graph TD
  65cc79b1_8edb_cd69_028d_79112318d9c7["MustBindWith()"]
  aec92911_ee4b_8bcc_393e_355587f08835["Bind()"]
  aec92911_ee4b_8bcc_393e_355587f08835 -->|calls| 65cc79b1_8edb_cd69_028d_79112318d9c7
  5564428a_4a19_8e4c_f07c_1a5fbeeff33b["BindJSON()"]
  5564428a_4a19_8e4c_f07c_1a5fbeeff33b -->|calls| 65cc79b1_8edb_cd69_028d_79112318d9c7
  434bee8e_2302_e46a_5925_3ef806d039f9["BindXML()"]
  434bee8e_2302_e46a_5925_3ef806d039f9 -->|calls| 65cc79b1_8edb_cd69_028d_79112318d9c7
  8ecd0615_2197_f686_710a_b0b395b12112["BindQuery()"]
  8ecd0615_2197_f686_710a_b0b395b12112 -->|calls| 65cc79b1_8edb_cd69_028d_79112318d9c7
  c4cef479_e07f_8987_ee45_13e0d2b20c6b["BindYAML()"]
  c4cef479_e07f_8987_ee45_13e0d2b20c6b -->|calls| 65cc79b1_8edb_cd69_028d_79112318d9c7
  9a2cffdf_58c7_4a59_83f6_db497b153514["BindTOML()"]
  9a2cffdf_58c7_4a59_83f6_db497b153514 -->|calls| 65cc79b1_8edb_cd69_028d_79112318d9c7
  bd5f925a_8d61_b327_408c_495d8829e258["BindPlain()"]
  bd5f925a_8d61_b327_408c_495d8829e258 -->|calls| 65cc79b1_8edb_cd69_028d_79112318d9c7
  4ef944f0_6ec1_fc47_e559_35d81d9dc913["BindHeader()"]
  4ef944f0_6ec1_fc47_e559_35d81d9dc913 -->|calls| 65cc79b1_8edb_cd69_028d_79112318d9c7
  40896729_4925_f536_3001_ba3bf751dcb6["ShouldBindWith()"]
  65cc79b1_8edb_cd69_028d_79112318d9c7 -->|calls| 40896729_4925_f536_3001_ba3bf751dcb6
  3dc48013_1241_230c_bac7_039eeb595a5e["AbortWithError()"]
  65cc79b1_8edb_cd69_028d_79112318d9c7 -->|calls| 3dc48013_1241_230c_bac7_039eeb595a5e
  style 65cc79b1_8edb_cd69_028d_79112318d9c7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

context.go lines 810–827

func (c *Context) MustBindWith(obj any, b binding.Binding) error {
	err := c.ShouldBindWith(obj, b)
	if err != nil {
		var maxBytesErr *http.MaxBytesError

		// Note: When using sonic or go-json as JSON encoder, they do not propagate the http.MaxBytesError error
		// https://github.com/goccy/go-json/issues/485
		// https://github.com/bytedance/sonic/issues/800
		switch {
		case errors.As(err, &maxBytesErr):
			c.AbortWithError(http.StatusRequestEntityTooLarge, err).SetType(ErrorTypeBind) //nolint: errcheck
		default:
			c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind) //nolint: errcheck
		}
		return err
	}
	return nil
}

Domain

Subdomains

Frequently Asked Questions

What does MustBindWith() do?
MustBindWith() is a function in the gin codebase.
What does MustBindWith() call?
MustBindWith() calls 2 function(s): AbortWithError, ShouldBindWith.
What calls MustBindWith()?
MustBindWith() is called by 8 function(s): Bind, BindHeader, BindJSON, BindPlain, BindQuery, BindTOML, BindXML, BindYAML.

Analyze Your Own Codebase

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

Try Supermodel Free