Update kg core endpoint methods (#406)

This commit is contained in:
cybermaggedon 2025-06-02 13:49:29 +01:00 committed by GitHub
parent 2e577e900a
commit 8fc8880d51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 4 deletions

View file

@ -55,11 +55,13 @@ class EndpointManager:
StreamEndpoint(
endpoint_path = "/api/v1/import-core",
auth = auth,
method = "POST",
dispatcher = dispatcher_manager.dispatch_core_import(),
),
StreamEndpoint(
endpoint_path = "/api/v1/export-core",
auth = auth,
method = "GET",
dispatcher = dispatcher_manager.dispatch_core_export(),
),
]

View file

@ -8,12 +8,13 @@ logger.setLevel(logging.INFO)
class StreamEndpoint:
def __init__(self, endpoint_path, auth, dispatcher):
def __init__(self, endpoint_path, auth, dispatcher, method="POST"):
self.path = endpoint_path
self.auth = auth
self.operation = "service"
self.method = method
self.dispatcher = dispatcher
@ -22,9 +23,16 @@ class StreamEndpoint:
def add_routes(self, app):
app.add_routes([
web.post(self.path, self.handle),
])
if self.method == "POST":
app.add_routes([
web.post(self.path, self.handle),
])
elif self.method == "GET":
app.add_routes([
web.get(self.path, self.handle),
])
else:
raise RuntimeError("Bad method" + self.method)
async def handle(self, request):