aboutsummaryrefslogtreecommitdiff
path: root/lib/API.hs
diff options
context:
space:
mode:
authorstuebinm2022-07-02 00:16:02 +0200
committerstuebinm2022-07-02 00:35:34 +0200
commit6c25964c0165530e7db6650eea79cbac99031353 (patch)
tree2b821e5e07320c211a8af0e70974cbbe6defef9e /lib/API.hs
parent6b4e8ba88f35538d62bb78b9872bc298178cf96d (diff)
gtfs realtime proof of concept
this adds a package for protobuf stuff, generated via hprotoc. Seems to work kinda fine? (the generated API is horrible though, will have to write some wrappers for that)
Diffstat (limited to 'lib/API.hs')
-rw-r--r--lib/API.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/API.hs b/lib/API.hs
index 51c3690..34b127a 100644
--- a/lib/API.hs
+++ b/lib/API.hs
@@ -5,7 +5,7 @@
-- | The sole authorative definition of this server's API, given as a Servant-style
-- Haskell type. All other descriptions of the API are generated from this one.
-module API (API, CompleteAPI) where
+module API (API, CompleteAPI, GtfsRealtimeAPI) where
import Data.Map (Map)
import Data.Proxy (Proxy (..))
@@ -21,6 +21,10 @@ import Servant (Application,
import Servant.API (Capture, FromHttpApiData, Get, JSON,
Post, QueryParam, ReqBody,
type (:<|>) ((:<|>)))
+import Servant.GTFS.Realtime (Proto)
+import GTFS.Realtime.FeedEntity
+import GTFS.Realtime.FeedMessage (FeedMessage)
+
-- | The server's API (as it is actually intended).
type API = "stations" :> Get '[JSON] (Map StationID Station)
@@ -33,6 +37,13 @@ type API = "stations" :> Get '[JSON] (Map StationID Station)
:<|> "train" :> "ping" :> ReqBody '[JSON] TripPing :> Post '[JSON] ()
-- debug things
:<|> "debug" :> "state" :> Get '[JSON] (Map Token [TripPing])
+ :<|> "gtfs" :> GtfsRealtimeAPI
+
+-- | The API used for publishing gtfs realtime updates
+type GtfsRealtimeAPI = "servicealerts" :> Get '[Proto] FeedMessage
+ :<|> "tripupdates" :> Get '[Proto] FeedEntity
+ :<|> "vehiclepositions" :> Get '[Proto] FeedEntity
+
-- | The server's API with an additional debug route for accessing the specification
-- itself. Split from API to prevent the API documenting the format in which it is