Add bwegt efa client
This commit is contained in:
parent
dcc3cfa44f
commit
740b654be6
33
main.go
33
main.go
@ -111,6 +111,38 @@ func (c KVVEFAClient) BuildRequest(stopId string) (*http.Request, error) {
|
||||
return req, nil
|
||||
}
|
||||
|
||||
type BwegtEFAClient struct {
|
||||
}
|
||||
|
||||
func (c BwegtEFAClient) GetName() string {
|
||||
return "bwegt"
|
||||
}
|
||||
|
||||
func (c BwegtEFAClient) BuildRequest(stopId string) (*http.Request, error) {
|
||||
// Create request object
|
||||
req, err := http.NewRequest("GET", "https://www.bwegt.de/bwegt-efa/XML_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 {
|
||||
@ -206,6 +238,7 @@ func main() {
|
||||
// Use round-robin to send incoming requests to different servers
|
||||
var efaClient atomic.Uint64
|
||||
efaClients := []EFAClient{
|
||||
BwegtEFAClient{},
|
||||
VRNEFAClient{},
|
||||
KVVEFAClient{},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user