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

Method GetViewData

context/context.go:3768–3783  ·  view source on GitHub ↗

GetViewData returns the values registered by `context#ViewData`. The return value is `map[string]interface{}`, this means that if a custom struct registered to ViewData then this function will try to parse it to map, if failed then the return value is nil A check for nil is always a good practise if

()

Source from the content-addressed store, hash-verified

3766// Similarly to `viewData := ctx.Values().Get("iris.view.data")` or
3767// `viewData := ctx.Values().Get(ctx.Application().ConfigurationReadOnly().GetViewDataContextKey())`.
3768func (ctx *Context) GetViewData() map[string]interface{} {
3769 if v := ctx.values.Get(ctx.app.ConfigurationReadOnly().GetViewDataContextKey()); v != nil {
3770 // if pure map[string]interface{}
3771 if viewData, ok := v.(Map); ok {
3772 return viewData
3773 }
3774
3775 // if struct, convert it to map[string]interface{}
3776 if structs.IsStruct(v) {
3777 return structs.Map(v)
3778 }
3779 }
3780
3781 // if no values found, then return nil
3782 return nil
3783}
3784
3785// FallbackViewProvider is an interface which can be registered to the `Party.FallbackView`
3786// or `Context.FallbackView` methods to handle fallback views.

Callers 4

HelloFunction · 0.80
EndRequestMethod · 0.80
writeModelsFunction · 0.80
ExecuteWriterMethod · 0.80

Calls 3

GetMethod · 0.65
GetViewDataContextKeyMethod · 0.65
ConfigurationReadOnlyMethod · 0.65

Tested by 2

EndRequestMethod · 0.64
writeModelsFunction · 0.64