refactor: use errors.Is()/errors.AsType() for error comparison and rename shadowed variables
Replace direct error equality checks (err == pgx.ErrNoRows, err != http.ErrServerClosed) with the idiomatic errors.Is() function throughout handlers, services, middleware, and app startup. This correctly handles wrapped error chains. Also replace a raw type assertion (*HTTPError) with errors.AsType[*HTTPError]() in the error handler middleware for consistency. Additionally, rename shadowed variables for clarity: - sidecar.go: config -> sidecarConfig, systemConfig (shadowed package-level vars) - media_scanner.go: uuid -> uuidString (shadowed the uuid package import)
This commit is contained in:
@@ -171,7 +171,7 @@ func (h *SidecarHandler) GetSidecarConfig(c *echo.Context) error {
|
||||
}
|
||||
|
||||
// Build sidecar config
|
||||
config := SidecarConfig{
|
||||
sidecarConfig := SidecarConfig{
|
||||
Version: "1.0",
|
||||
Bookhoard: SidecarBookhoardConfig{
|
||||
OPDSCatalog: opdsCatalogURL,
|
||||
@@ -188,7 +188,7 @@ func (h *SidecarHandler) GetSidecarConfig(c *echo.Context) error {
|
||||
LastUpdated: time.Now().Format(time.RFC3339),
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, config)
|
||||
return c.JSON(http.StatusOK, sidecarConfig)
|
||||
}
|
||||
|
||||
// DownloadSidecarConfig generates a .bookhoard.json file for device setup
|
||||
@@ -352,8 +352,8 @@ func (h *SidecarHandler) GetSystemConfiguration(c *echo.Context) error {
|
||||
|
||||
// Build config map
|
||||
result := make(map[string]string)
|
||||
for _, config := range configs {
|
||||
result[config.Key] = config.Value
|
||||
for _, systemConfig := range configs {
|
||||
result[systemConfig.Key] = systemConfig.Value
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, result)
|
||||
|
||||
Reference in New Issue
Block a user