mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
Update kg core endpoint methods (#406)
This commit is contained in:
parent
2e577e900a
commit
8fc8880d51
2 changed files with 14 additions and 4 deletions
|
|
@ -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(),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue