MCPcopy
hub / github.com/gin-gonic/gin / Render

Method Render

context.go:1152–1166  ·  view source on GitHub ↗

Render writes the response headers and calls render.Render to render data.

(code int, r render.Render)

Source from the content-addressed store, hash-verified

1150
1151// Render writes the response headers and calls render.Render to render data.
1152func (c *Context) Render(code int, r render.Render) {
1153 c.Status(code)
1154
1155 if !bodyAllowedForStatus(code) {
1156 r.WriteContentType(c.Writer)
1157 c.Writer.WriteHeaderNow()
1158 return
1159 }
1160
1161 if err := r.Render(c.Writer); err != nil {
1162 // Pushing error to c.Errors
1163 _ = c.Error(err)
1164 c.Abort()
1165 }
1166}
1167
1168// HTML renders the HTTP template specified by its file name.
1169// It also updates the HTTP code and sets the Content-Type as "text/html".

Callers 15

HTMLMethod · 0.95
IndentedJSONMethod · 0.95
SecureJSONMethod · 0.95
JSONPMethod · 0.95
JSONMethod · 0.95
AsciiJSONMethod · 0.95
PureJSONMethod · 0.95
XMLMethod · 0.95
YAMLMethod · 0.95
TOMLMethod · 0.95
ProtoBufMethod · 0.95
BSONMethod · 0.95

Calls 7

StatusMethod · 0.95
ErrorMethod · 0.95
AbortMethod · 0.95
bodyAllowedForStatusFunction · 0.85
WriteContentTypeMethod · 0.65
WriteHeaderNowMethod · 0.65
RenderMethod · 0.65

Tested by

no test coverage detected