This commit is contained in:
parent
1c1aad5846
commit
a563cc45b5
@ -11,3 +11,4 @@
|
||||
- [x] Transfer using JSON
|
||||
- [x] Correctly implement basic auth
|
||||
- [ ] Use unidecode to replace non-ascii stuff in the backend
|
||||
- [ ] Add query parameter for selecting EFAClient
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
vrnp-static = pkgs.buildGoModule {
|
||||
pname = "vrnp";
|
||||
version = "0.0.8";
|
||||
version = "0.0.9";
|
||||
vendorHash = null;
|
||||
|
||||
# For building the package, we use only the files not ignored by Git as inputs.
|
||||
|
35
main.go
35
main.go
@ -55,6 +55,7 @@ var allEfaClients []EFAClient = []EFAClient{
|
||||
BwegtEFAClient{},
|
||||
VRNEFAClient{},
|
||||
KVVEFAClient{},
|
||||
VAGEFAClient{},
|
||||
}
|
||||
|
||||
type VRNEFAClient struct {
|
||||
@ -151,6 +152,38 @@ func (c BwegtEFAClient) BuildRequest(stopId string) (*http.Request, error) {
|
||||
return req, nil
|
||||
}
|
||||
|
||||
type VAGEFAClient struct {
|
||||
}
|
||||
|
||||
func (c VAGEFAClient) GetName() string {
|
||||
return "VAG"
|
||||
}
|
||||
|
||||
func (c VAGEFAClient) BuildRequest(stopId string) (*http.Request, error) {
|
||||
// Create request object
|
||||
req, err := http.NewRequest("GET", "https://efa.vagfr.de/vagfr3/XSLT_DM_REQUEST", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Configure our request
|
||||
query := url.Values{}
|
||||
query.Set("coordOutputFormat", "EPSG:4326")
|
||||
query.Set("depType", "stopEvents")
|
||||
query.Set("includeCompleteStopSeq", "0")
|
||||
query.Set("limit", "10")
|
||||
query.Set("locationServerActive", "0")
|
||||
query.Set("mode", "direct")
|
||||
query.Set("name_dm", stopId)
|
||||
query.Set("outputFormat", "json")
|
||||
query.Set("type_dm", "stop")
|
||||
query.Set("useOnlyStops", "1")
|
||||
query.Set("useRealtime", "1")
|
||||
req.URL.RawQuery = query.Encode()
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func FetchDepartures(c EFAClient, stopId string) (DMResponse, error) {
|
||||
req, err := c.BuildRequest(stopId)
|
||||
if err != nil {
|
||||
@ -281,7 +314,7 @@ func main() {
|
||||
platform = &query["platform"][0]
|
||||
}
|
||||
|
||||
c := efaClients[(efaClient.Add(1)-1)%uint64(len(efaClients))]
|
||||
c := efaClients[(efaClient.Add(1) - 1) % uint64(len(efaClients))]
|
||||
ds, err := FetchDepartures(c, stopId)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
Loading…
x
Reference in New Issue
Block a user