make it work for my tram board

adds webserer with endpoint /line?number=3

you need to specify a post body text using b64-encoded, semicolon-separated names of the stops

index of stop name corresponds to returned value (led index)
This commit is contained in:
2026-07-03 11:41:25 +02:00
parent 3b84fad254
commit 96f8cfa55c
5 changed files with 194 additions and 29 deletions

View File

@@ -0,0 +1,34 @@
package timetable
import (
"encoding/json"
"fmt"
"log"
"net/http"
"shellixa/puvetra/internal/types"
)
func GetTrip(tripId string) types.Trip {
client := http.Client{}
url := fmt.Sprintf("https://api.transitous.org/api/v6/trip?tripId=%s", tripId)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatal(err)
}
response, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer response.Body.Close()
var trip types.Trip
if err := json.NewDecoder(response.Body).Decode(&trip); err != nil {
log.Fatal(err)
}
return trip
}