fix: address code review findings
This commit is contained in:
@@ -205,6 +205,18 @@ func RouteSearch(hc *HandlerContext, w http.ResponseWriter, r *http.Request) {
|
||||
RankingMode: rankingMode,
|
||||
}
|
||||
|
||||
// Determine if this is a far-term search (date is more than 7 days in the future)
|
||||
if req.Date != "" {
|
||||
requestDate, err := time.Parse("2006-01-02", req.Date)
|
||||
if err == nil {
|
||||
now := time.Now()
|
||||
daysDiff := int(requestDate.Sub(now).Hours() / 24)
|
||||
if daysDiff >= 7 {
|
||||
opts.FarTerm = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Detect closed stations and get neighbors for fallback
|
||||
closedStationsMap := make(map[string]bool)
|
||||
neighborsMap := make(map[string][]storage.StationNeighbor)
|
||||
@@ -431,7 +443,7 @@ func StationStatus(hc *HandlerContext, w http.ResponseWriter, r *http.Request) {
|
||||
func adminAuth(hc *HandlerContext, w http.ResponseWriter, r *http.Request) bool {
|
||||
expectedAPIKey := os.Getenv("TRIP_PLANNER_ADMIN_API_KEY")
|
||||
if expectedAPIKey == "" {
|
||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||
http.Error(w, "server configuration error: TRIP_PLANNER_ADMIN_API_KEY is not set", http.StatusInternalServerError)
|
||||
return false
|
||||
}
|
||||
providedAPIKey := r.Header.Get("X-Admin-Api-Key")
|
||||
|
||||
Reference in New Issue
Block a user