package main import ( "encoding/json" "log" "net/http" "time" "github.com/go-redis/redis/v8" "trip-planner/internal/cache" "trip-planner/internal/routing" "trip-planner/internal/yandex" ) // HandlerContext holds the dependencies for API handlers. type HandlerContext struct { Cache cache.Cache Redis *redis.Client Router *routing.Graph Yandex *yandex.Client SearchCache *routing.SearchCacheService } // NewHandlerContext creates a new HandlerContext with initialized services. func NewHandlerContext(redisClient *redis.Client, router *routing.Graph, yandex *yandex.Client) *HandlerContext { cacheStore := cache.NewCacheStore(redisClient) return &HandlerContext{ Cache: cacheStore, Redis: redisClient, Router: router, Yandex: yandex, SearchCache: routing.NewSearchCacheService(cache.NewCacheAside(cacheStore), yandex), } }