A new middleware aborts any requests which require the data cache if the cache is not yet initialized. An explicit error is returned so the admin will be immediately aware what has gone wrong. Previously, webpages were rendered and JSON responses were sent with zero values, and with no indication of anything being wrong. This was sometimes difficult to notice, and even when noticed the cause was not immediately apparent.
21 lines
414 B
Go
21 lines
414 B
Go
// Copyright (c) 2020-2022 The Decred developers
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package webapi
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (w *WebAPI) homepage(c *gin.Context) {
|
|
cacheData := c.MustGet(cacheKey).(cacheData)
|
|
|
|
c.HTML(http.StatusOK, "homepage.html", gin.H{
|
|
"WebApiCache": cacheData,
|
|
"WebApiCfg": w.cfg,
|
|
})
|
|
}
|