MCPcopy
hub / github.com/gofiber/fiber / ReloadViews

Method ReloadViews

app.go:867–908  ·  view source on GitHub ↗

ReloadViews reloads the configured view engine by invoking its Load method. It returns an error if no view engine is configured or if reloading fails.

()

Source from the content-addressed store, hash-verified

865// ReloadViews reloads the configured view engine by invoking its Load method.
866// It returns an error if no view engine is configured or if reloading fails.
867func (app *App) ReloadViews() error {
868 app.mutex.Lock()
869 defer app.mutex.Unlock()
870
871 apps := map[string]*App{"": app}
872 if app.mountFields != nil {
873 apps = app.mountFields.appList
874 }
875
876 var reloaded bool
877 for _, targetApp := range apps {
878 if targetApp == nil || targetApp.config.Views == nil {
879 continue
880 }
881
882 if viewValue := reflect.ValueOf(targetApp.config.Views); viewValue.Kind() == reflect.Pointer && viewValue.IsNil() {
883 continue
884 }
885
886 if err := func() error {
887 viewsLock := getViewsLock(targetApp.config.Views)
888 viewsLock.Lock()
889 defer viewsLock.Unlock()
890
891 if err := targetApp.config.Views.Load(); err != nil {
892 return fmt.Errorf("fiber: failed to reload views: %w", err)
893 }
894
895 return nil
896 }(); err != nil {
897 return err
898 }
899
900 reloaded = true
901 }
902
903 if !reloaded {
904 return ErrNoViewEngineConfigured
905 }
906
907 return nil
908}
909
910// SetTLSHandler Can be used to set ClientHelloInfo when using TLS with Listener.
911func (app *App) SetTLSHandler(tlsHandler *TLSHandler) {

Calls 5

getViewsLockFunction · 0.85
LockMethod · 0.65
UnlockMethod · 0.65
LoadMethod · 0.65
ErrorfMethod · 0.65