mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-25 08:44:33 +00:00
sig->activity and multiple activity changes for API v3. #143
This commit is contained in:
+131
-19
@@ -17,6 +17,34 @@ from core.data_providers import DATA_PROVIDERS
|
||||
from core.data_store import DATA_STORE
|
||||
from webserver.handlers.api.addspot import APISpotHandler
|
||||
from webserver.handlers.api.alerts import APIAlertsHandler, APIAlertsStreamHandler
|
||||
from webserver.handlers.api.compatibility.v1_compatibility import (
|
||||
V1APIAlertsHandler,
|
||||
V1APIAlertsStreamHandler,
|
||||
V1APIDxStatsHandler,
|
||||
V1APILookupCallHandler,
|
||||
V1APILookupGridHandler,
|
||||
V1APILookupSigRefHandler,
|
||||
V1APIOptionsHandler,
|
||||
V1APISolarConditionsHandler,
|
||||
V1APISpotHandler,
|
||||
V1APISpotsHandler,
|
||||
V1APISpotsStreamHandler,
|
||||
V1APIStatusHandler,
|
||||
)
|
||||
from webserver.handlers.api.compatibility.v2_compatibility import (
|
||||
V2APIAlertsHandler,
|
||||
V2APIAlertsStreamHandler,
|
||||
V2APIDxStatsHandler,
|
||||
V2APILookupCallHandler,
|
||||
V2APILookupGridHandler,
|
||||
V2APILookupSigRefHandler,
|
||||
V2APIOptionsHandler,
|
||||
V2APISolarConditionsHandler,
|
||||
V2APISpotHandler,
|
||||
V2APISpotsHandler,
|
||||
V2APISpotsStreamHandler,
|
||||
V2APIStatusHandler,
|
||||
)
|
||||
from webserver.handlers.api.dxstats import APIDxStatsHandler
|
||||
from webserver.handlers.api.lookups import (
|
||||
APILookupActivityRefHandler,
|
||||
@@ -27,9 +55,6 @@ from webserver.handlers.api.options import APIOptionsHandler
|
||||
from webserver.handlers.api.solar_conditions import APISolarConditionsHandler
|
||||
from webserver.handlers.api.spots import APISpotsHandler, APISpotsStreamHandler
|
||||
from webserver.handlers.api.status import APIStatusHandler
|
||||
from webserver.handlers.api.v1_addspot import V1APISpotHandler
|
||||
from webserver.handlers.api.v1_compatability import V1RedirectHandler
|
||||
from webserver.handlers.api.v1_spots import V1APISpotsHandler, V1APISpotsStreamHandler
|
||||
from webserver.handlers.manifesthandler import ManifestHandler
|
||||
from webserver.handlers.metrics import PrometheusMetricsHandler
|
||||
from webserver.handlers.pagetemplate import PageTemplateHandler
|
||||
@@ -107,50 +132,50 @@ class WebServer:
|
||||
# API endpoints are always enabled
|
||||
api_routes = [
|
||||
(
|
||||
r"/api/v2/spots",
|
||||
r"/api/v3/spots",
|
||||
APISpotsHandler,
|
||||
{"spots": self._data_store.spots},
|
||||
),
|
||||
(
|
||||
r"/api/v2/alerts",
|
||||
r"/api/v3/alerts",
|
||||
APIAlertsHandler,
|
||||
{"alerts": self._data_store.alerts},
|
||||
),
|
||||
(
|
||||
r"/api/v2/spots/stream",
|
||||
r"/api/v3/spots/stream",
|
||||
APISpotsStreamHandler,
|
||||
{"sse_spot_broadcaster": self._spot_broadcaster},
|
||||
),
|
||||
(
|
||||
r"/api/v2/alerts/stream",
|
||||
r"/api/v3/alerts/stream",
|
||||
APIAlertsStreamHandler,
|
||||
{"sse_alert_broadcaster": self._alert_broadcaster},
|
||||
),
|
||||
(
|
||||
r"/api/v2/solar",
|
||||
r"/api/v3/solar",
|
||||
APISolarConditionsHandler,
|
||||
{"solar_conditions": self._data_store.solar_conditions.get()},
|
||||
),
|
||||
(
|
||||
r"/api/v2/dxstats",
|
||||
r"/api/v3/dxstats",
|
||||
APIDxStatsHandler,
|
||||
{"spots": self._data_store.spots},
|
||||
),
|
||||
(
|
||||
r"/api/v2/options",
|
||||
r"/api/v3/options",
|
||||
APIOptionsHandler,
|
||||
{"status_data": self._data_store.status.get()},
|
||||
),
|
||||
(
|
||||
r"/api/v2/status",
|
||||
r"/api/v3/status",
|
||||
APIStatusHandler,
|
||||
{"status_data": self._data_store.status.get()},
|
||||
),
|
||||
(r"/api/v2/lookup/call", APILookupCallHandler),
|
||||
(r"/api/v2/lookup/sigref", APILookupActivityRefHandler),
|
||||
(r"/api/v2/lookup/grid", APILookupGridHandler),
|
||||
(r"/api/v3/lookup/call", APILookupCallHandler),
|
||||
(r"/api/v3/lookup/activityref", APILookupActivityRefHandler),
|
||||
(r"/api/v3/lookup/grid", APILookupGridHandler),
|
||||
(
|
||||
r"/api/v2/spot",
|
||||
r"/api/v3/spot",
|
||||
APISpotHandler,
|
||||
{
|
||||
"spots": self._data_store.spots,
|
||||
@@ -159,27 +184,114 @@ class WebServer:
|
||||
),
|
||||
]
|
||||
|
||||
# v1 API redirects. Most v1 enpoints are unchanged in v2, and get an HTTP 308 redirect to the v2 API. The ones
|
||||
# that have the major breaking changes get a bespoke handler.
|
||||
# v2 API compatibility routes. Translation wrappers convert data to the v3 format and back.
|
||||
v2_compat_routes = [
|
||||
(
|
||||
r"/api/v2/spots",
|
||||
V2APISpotsHandler,
|
||||
{"spots": self._data_store.spots},
|
||||
),
|
||||
(
|
||||
r"/api/v2/alerts",
|
||||
V2APIAlertsHandler,
|
||||
{"alerts": self._data_store.alerts},
|
||||
),
|
||||
(
|
||||
r"/api/v2/spots/stream",
|
||||
V2APISpotsStreamHandler,
|
||||
{"sse_spot_broadcaster": self._spot_broadcaster},
|
||||
),
|
||||
(
|
||||
r"/api/v2/alerts/stream",
|
||||
V2APIAlertsStreamHandler,
|
||||
{"sse_alert_broadcaster": self._alert_broadcaster},
|
||||
),
|
||||
(
|
||||
r"/api/v2/solar",
|
||||
V2APISolarConditionsHandler,
|
||||
{"solar_conditions": self._data_store.solar_conditions.get()},
|
||||
),
|
||||
(
|
||||
r"/api/v2/dxstats",
|
||||
V2APIDxStatsHandler,
|
||||
{"spots": self._data_store.spots},
|
||||
),
|
||||
(
|
||||
r"/api/v2/options",
|
||||
V2APIOptionsHandler,
|
||||
{"status_data": self._data_store.status.get()},
|
||||
),
|
||||
(
|
||||
r"/api/v2/status",
|
||||
V2APIStatusHandler,
|
||||
{"status_data": self._data_store.status.get()},
|
||||
),
|
||||
(r"/api/v2/lookup/call", V2APILookupCallHandler),
|
||||
(r"/api/v2/lookup/sigref", V2APILookupSigRefHandler),
|
||||
(r"/api/v2/lookup/grid", V2APILookupGridHandler),
|
||||
(
|
||||
r"/api/v2/spot",
|
||||
V2APISpotHandler,
|
||||
{
|
||||
"spots": self._data_store.spots,
|
||||
"spot_providers": self._data_providers,
|
||||
},
|
||||
),
|
||||
]
|
||||
|
||||
# Translation wrappers convert data to the v3 format and back.
|
||||
v1_compat_routes = [
|
||||
(
|
||||
r"/api/v1/spots",
|
||||
V1APISpotsHandler,
|
||||
{"spots": self._data_store.spots},
|
||||
),
|
||||
(
|
||||
r"/api/v1/alerts",
|
||||
V1APIAlertsHandler,
|
||||
{"alerts": self._data_store.alerts},
|
||||
),
|
||||
(
|
||||
r"/api/v1/spots/stream",
|
||||
V1APISpotsStreamHandler,
|
||||
{"sse_spot_broadcaster": self._spot_broadcaster},
|
||||
),
|
||||
(
|
||||
r"/api/v1/alerts/stream",
|
||||
V1APIAlertsStreamHandler,
|
||||
{"sse_alert_broadcaster": self._alert_broadcaster},
|
||||
),
|
||||
(
|
||||
r"/api/v1/solar",
|
||||
V1APISolarConditionsHandler,
|
||||
{"solar_conditions": self._data_store.solar_conditions.get()},
|
||||
),
|
||||
(
|
||||
r"/api/v1/dxstats",
|
||||
V1APIDxStatsHandler,
|
||||
{"spots": self._data_store.spots},
|
||||
),
|
||||
(
|
||||
r"/api/v1/options",
|
||||
V1APIOptionsHandler,
|
||||
{"status_data": self._data_store.status.get()},
|
||||
),
|
||||
(
|
||||
r"/api/v1/status",
|
||||
V1APIStatusHandler,
|
||||
{"status_data": self._data_store.status.get()},
|
||||
),
|
||||
(r"/api/v1/lookup/call", V1APILookupCallHandler),
|
||||
(r"/api/v1/lookup/sigref", V1APILookupSigRefHandler),
|
||||
(r"/api/v1/lookup/grid", V1APILookupGridHandler),
|
||||
(
|
||||
r"/api/v1/spot",
|
||||
V1APISpotHandler,
|
||||
{
|
||||
"spots": self._data_store.spots,
|
||||
"spot_providers": self._data_providers,
|
||||
},
|
||||
),
|
||||
(r"/api/v1/(.*)", V1RedirectHandler),
|
||||
]
|
||||
|
||||
# If in API-only mode, serve a basic homepage; in normal mode, serve the usual UI routes
|
||||
@@ -253,7 +365,7 @@ class WebServer:
|
||||
]
|
||||
|
||||
app = tornado.web.Application(
|
||||
api_routes + v1_compat_routes + ui_routes + misc_routes,
|
||||
api_routes + v2_compat_routes + v1_compat_routes + ui_routes + misc_routes,
|
||||
template_path=os.path.join(_HERE, "../templates"),
|
||||
log_function=request_log,
|
||||
debug=False,
|
||||
|
||||
Reference in New Issue
Block a user