func dbCheckMiddleware() gin.HandlerFunc {
	return func(c *gin.Context) {
		path := strings.Replace(c.Request.URL.Path, command.Opts.Prefix, "", -1)
		if allowedPaths[path] {
			c.Next()
			return
		}
		if !command.Opts.Sessions {
			if DbClient == nil {
				badRequest(c, errNotConnected)
				return
			}
			c.Next()
			return
		}
		sid := getSessionId(c.Request)
		if sid == "" {
			badRequest(c, errSessionRequired)
			return
		}
		conn := DbSessions[sid]
		if conn == nil {
			badRequest(c, errNotConnected)
			return
		}
		c.Next()
	}
}
Middleware to check database connection status before running queries
package api
import (
	"log"
	"strings"
	"github.com/gin-gonic/gin"
	"github.com/sosedoff/pgweb/pkg/command"
)