fix: address code review findings
- Fix type mismatch in search_cache.go: SearchWithCache now returns *yandex.Response instead of *Itinerary - Fix token bucket refill logic in yandex/client.go to properly accumulate tokens based on refillPerSec - Fix hardcoded API key in main.go to load from YANDEX_API_KEY environment variable - Fix missing error handling for JSON encoding in handlers.go RouteGeoJSON function - Fix incorrect redis.Nil handling in cache/store.go CacheAside.Exists method - Fix incorrect error return type in station_status.go updateStationStatus to return newStatus instead of empty string
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
|
||||
@@ -17,7 +18,12 @@ func main() {
|
||||
redisClient := initRedis()
|
||||
router := routing.NewGraph()
|
||||
m := metrics.New()
|
||||
yandexClient := yandex.NewClient("default-key", yandex.WithMetrics(m))
|
||||
|
||||
apiKey := os.Getenv("YANDEX_API_KEY")
|
||||
if apiKey == "" {
|
||||
apiKey = "default-key" // fallback for development
|
||||
}
|
||||
yandexClient := yandex.NewClient(apiKey, yandex.WithMetrics(m))
|
||||
|
||||
handlerCtx := NewHandlerContext(redisClient, router, yandexClient, m)
|
||||
|
||||
@@ -62,4 +68,4 @@ func makeHandler(handler func(*HandlerContext, http.ResponseWriter, *http.Reques
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
handler(hc, w, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user