mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-24 04:31:02 +02:00
Update kg core endpoint methods
This commit is contained in:
parent
2e577e900a
commit
7cfa40c85c
2 changed files with 14 additions and 4 deletions
|
|
@ -55,11 +55,13 @@ class EndpointManager:
|
||||||
StreamEndpoint(
|
StreamEndpoint(
|
||||||
endpoint_path = "/api/v1/import-core",
|
endpoint_path = "/api/v1/import-core",
|
||||||
auth = auth,
|
auth = auth,
|
||||||
|
method = "POST",
|
||||||
dispatcher = dispatcher_manager.dispatch_core_import(),
|
dispatcher = dispatcher_manager.dispatch_core_import(),
|
||||||
),
|
),
|
||||||
StreamEndpoint(
|
StreamEndpoint(
|
||||||
endpoint_path = "/api/v1/export-core",
|
endpoint_path = "/api/v1/export-core",
|
||||||
auth = auth,
|
auth = auth,
|
||||||
|
method = "GET",
|
||||||
dispatcher = dispatcher_manager.dispatch_core_export(),
|
dispatcher = dispatcher_manager.dispatch_core_export(),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,13 @@ logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
class StreamEndpoint:
|
class StreamEndpoint:
|
||||||
|
|
||||||
def __init__(self, endpoint_path, auth, dispatcher):
|
def __init__(self, endpoint_path, auth, dispatcher, method="POST"):
|
||||||
|
|
||||||
self.path = endpoint_path
|
self.path = endpoint_path
|
||||||
|
|
||||||
self.auth = auth
|
self.auth = auth
|
||||||
self.operation = "service"
|
self.operation = "service"
|
||||||
|
self.method = method
|
||||||
|
|
||||||
self.dispatcher = dispatcher
|
self.dispatcher = dispatcher
|
||||||
|
|
||||||
|
|
@ -22,9 +23,16 @@ class StreamEndpoint:
|
||||||
|
|
||||||
def add_routes(self, app):
|
def add_routes(self, app):
|
||||||
|
|
||||||
app.add_routes([
|
if self.method == "POST":
|
||||||
web.post(self.path, self.handle),
|
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):
|
async def handle(self, request):
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue