Disallow routing to departing station

This commit is contained in:
clerie 2024-07-28 15:25:49 +02:00
parent afee3b0c6f
commit 864c94ea94

View File

@ -194,6 +194,10 @@ async fn route_station_to_dest_station(
return Err((StatusCode::NOT_FOUND, String::from("Unknown destination station")));
}
if dest_station_id == station_id {
return Err((StatusCode::NOT_FOUND, String::from("Cannot route to departing station as destination")));
}
let station_properties = match state.stations.get(&station_id) {
Some(v) => v,
None => return Err((StatusCode::INTERNAL_SERVER_ERROR, String::from("Station properties for departing station missing"))),