diff --git a/src/main.rs b/src/main.rs
index 48b7614..3b8f02f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -115,7 +115,7 @@ async fn main() {
let app = Router::new()
.route("/", get(route_index))
- .route("/station/:station", get(route_station_overview))
+ .route("/station/:station_id", get(route_station_overview))
.route("/station/:station_id/to/:dest_station_id", get(route_station_to_dest_station))
.with_state(state);
@@ -130,7 +130,11 @@ async fn route_index(
) -> Result, String> {
let mut out = String::new();
- out.push_str("
\n");
+ out.push_str("\n");
+ out.push_str("Nur ausstieg
\n");
+ out.push_str("Es gibt Züge die innerhalb Berlins fahren, aber nicht im Fahrplan Routing der DB auftauchen, weil sie entweder in Berlin enden oder in Berlin beginnen.
\n");
+ out.push_str("Diese Seite zeigt für verschiene Stationen genau diese Züge an.
\n");
+ out.push_str("\n");
for (id, station) in state.stations.into_iter() {
out.push_str(&format!("- {}
\n", id, station.name));
@@ -143,18 +147,25 @@ async fn route_index(
async fn route_station_overview(
State(state): State,
- Path(station): Path
+ Path(station_id): Path
) -> Result, (StatusCode, String)> {
- if !state.stations.contains_key(&station) {
+ if !state.stations.contains_key(&station_id) {
return Err((StatusCode::NOT_FOUND, String::from("Unknown departing station")));
}
+ 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"))),
+ };
+
let mut out = String::new();
- out.push_str("\n");
+ out.push_str("\n");
+ out.push_str(&format!("Ziele für {}
\n", station_properties.name));
+ out.push_str("\n");
for (dest_station_id, dest_station) in state.stations.into_iter() {
- out.push_str(&format!("- {}
\n", station, dest_station_id, dest_station.name));
+ out.push_str(&format!("- {}
\n", station_id, dest_station_id, dest_station.name));
}
out.push_str("
\n");
@@ -202,7 +213,9 @@ async fn route_station_to_dest_station(
let mut out = String::new();
- out.push_str("\n");
+ out.push_str("\n");
+ out.push_str(&format!("Abfahren für {} nach {}
\n", station_properties.name, dest_station_properties.name));
+ out.push_str("\n");
for departure in stationdata.departures {
let departure_info = match departure.departure {