MCPcopy Create free account
hub / github.com/kataras/iris / RenderComponent

Method RenderComponent

context/context.go:4328–4335  ·  view source on GitHub ↗

RenderComponent renders a component to the client. It sets the "Content-Type" header to "text/html; charset=utf-8". It reports any component render errors back to the caller. Look the Application.SetContextErrorHandler to override the default status code 500 with a custom error response.

(component Component)

Source from the content-addressed store, hash-verified

4326// Look the Application.SetContextErrorHandler to override the
4327// default status code 500 with a custom error response.
4328func (ctx *Context) RenderComponent(component Component) error {
4329 ctx.ContentType("text/html; charset=utf-8")
4330 err := component.Render(ctx.Request().Context(), ctx.ResponseWriter())
4331 if err != nil {
4332 ctx.handleContextError(err)
4333 }
4334 return err
4335}
4336
4337// JSON marshals the given "v" value to JSON and writes the response to the client.
4338// Look the Configuration.EnableProtoJSON and EnableEasyJSON too.

Callers 1

ComponentFunction · 0.80

Calls 6

ContentTypeMethod · 0.95
RequestMethod · 0.95
ResponseWriterMethod · 0.95
handleContextErrorMethod · 0.95
ContextMethod · 0.80
RenderMethod · 0.65

Tested by

no test coverage detected