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

Method fireFallbackViewOnce

context/context.go:3849–3888  ·  view source on GitHub ↗
(err ErrViewNotExist)

Source from the content-addressed store, hash-verified

3847const fallbackViewOnce = "iris.fallback.view.once"
3848
3849func (ctx *Context) fireFallbackViewOnce(err ErrViewNotExist) error {
3850 // Note(@kataras): this is our way to keep the same View method for
3851 // both fallback and normal views, remember, we export the whole
3852 // Context functionality to the end-developer through the fallback view provider.
3853 if ctx.values.Get(fallbackViewOnce) != nil {
3854 return err
3855 }
3856
3857 v := ctx.values.Get(ctx.app.ConfigurationReadOnly().GetFallbackViewContextKey())
3858 if v == nil {
3859 return err
3860 }
3861
3862 providers, ok := v.([]FallbackViewProvider)
3863 if !ok {
3864 return err
3865 }
3866
3867 ctx.values.Set(fallbackViewOnce, struct{}{})
3868
3869 var pErr error
3870 for _, provider := range providers {
3871 pErr = provider.FallbackView(ctx, err)
3872 if pErr != nil {
3873 if vErr, ok := pErr.(ErrViewNotExist); ok {
3874 // This fallback view does not exist or it's not responsible to handle,
3875 // try the next.
3876 pErr = vErr
3877 continue
3878 }
3879 }
3880
3881 // If OK then we found the correct fallback.
3882 // If the error was a parse error and not a template not found
3883 // then exit and report the pErr error.
3884 break
3885 }
3886
3887 return pErr
3888}
3889
3890// FallbackView registers one or more fallback views for a template or a template layout.
3891// When View cannot find the given filename to execute then this "provider"

Callers 1

ViewMethod · 0.95

Calls 5

GetMethod · 0.65
ConfigurationReadOnlyMethod · 0.65
SetMethod · 0.65
FallbackViewMethod · 0.65

Tested by

no test coverage detected