Home / Function/ Negotiate() — gin Function Reference

Negotiate() — gin Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  08757a7b_89f3_7a60_ac08_6c15ecf7b5bd["Negotiate()"]
  eeea1018_1f11_4561_313c_6236f45a9d03["NegotiateFormat()"]
  08757a7b_89f3_7a60_ac08_6c15ecf7b5bd -->|calls| eeea1018_1f11_4561_313c_6236f45a9d03
  9c6f4db4_3d56_9165_ad9e_96feca54df85["JSON()"]
  08757a7b_89f3_7a60_ac08_6c15ecf7b5bd -->|calls| 9c6f4db4_3d56_9165_ad9e_96feca54df85
  65cb002a_8dad_6301_a5f6_025d54f0e6b6["HTML()"]
  08757a7b_89f3_7a60_ac08_6c15ecf7b5bd -->|calls| 65cb002a_8dad_6301_a5f6_025d54f0e6b6
  5237c496_fa61_722e_96a5_fb50a8549ee4["XML()"]
  08757a7b_89f3_7a60_ac08_6c15ecf7b5bd -->|calls| 5237c496_fa61_722e_96a5_fb50a8549ee4
  856e9c34_100d_80d0_e810_7439700b1f01["YAML()"]
  08757a7b_89f3_7a60_ac08_6c15ecf7b5bd -->|calls| 856e9c34_100d_80d0_e810_7439700b1f01
  fa323311_4e45_dfa8_0d23_27731edad8be["TOML()"]
  08757a7b_89f3_7a60_ac08_6c15ecf7b5bd -->|calls| fa323311_4e45_dfa8_0d23_27731edad8be
  19de2045_6ee9_28a1_dc7f_ea46f53ca048["ProtoBuf()"]
  08757a7b_89f3_7a60_ac08_6c15ecf7b5bd -->|calls| 19de2045_6ee9_28a1_dc7f_ea46f53ca048
  dc868146_10e5_dd59_9844_cb858e5b9016["BSON()"]
  08757a7b_89f3_7a60_ac08_6c15ecf7b5bd -->|calls| dc868146_10e5_dd59_9844_cb858e5b9016
  3dc48013_1241_230c_bac7_039eeb595a5e["AbortWithError()"]
  08757a7b_89f3_7a60_ac08_6c15ecf7b5bd -->|calls| 3dc48013_1241_230c_bac7_039eeb595a5e
  style 08757a7b_89f3_7a60_ac08_6c15ecf7b5bd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

context.go lines 1357–1390

func (c *Context) Negotiate(code int, config Negotiate) {
	switch c.NegotiateFormat(config.Offered...) {
	case binding.MIMEJSON:
		data := chooseData(config.JSONData, config.Data)
		c.JSON(code, data)

	case binding.MIMEHTML:
		data := chooseData(config.HTMLData, config.Data)
		c.HTML(code, config.HTMLName, data)

	case binding.MIMEXML:
		data := chooseData(config.XMLData, config.Data)
		c.XML(code, data)

	case binding.MIMEYAML, binding.MIMEYAML2:
		data := chooseData(config.YAMLData, config.Data)
		c.YAML(code, data)

	case binding.MIMETOML:
		data := chooseData(config.TOMLData, config.Data)
		c.TOML(code, data)

	case binding.MIMEPROTOBUF:
		data := chooseData(config.PROTOBUFData, config.Data)
		c.ProtoBuf(code, data)

	case binding.MIMEBSON:
		data := chooseData(config.BSONData, config.Data)
		c.BSON(code, data)

	default:
		c.AbortWithError(http.StatusNotAcceptable, errors.New("the accepted formats are not offered by the server")) //nolint: errcheck
	}
}

Domain

Subdomains

Frequently Asked Questions

What does Negotiate() do?
Negotiate() is a function in the gin codebase.
What does Negotiate() call?
Negotiate() calls 9 function(s): AbortWithError, BSON, HTML, JSON, NegotiateFormat, ProtoBuf, TOML, XML, and 1 more.

Analyze Your Own Codebase

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

Try Supermodel Free