Add endpoint to list all stream IDs that have been set up.
parent
dce4bbf3a8
commit
7a67544c38
|
@ -2,6 +2,8 @@ stream_api_port=21336
|
|||
|
||||
interactive.harbor(port=stream_api_port, uri="/interactive") # expose through stream API port
|
||||
|
||||
stream_api_streams=[]
|
||||
|
||||
def setup_harbor_stream_api(s) =
|
||||
def on_start(~protocol, ~data, ~headers, uri) =
|
||||
s.start()
|
||||
|
@ -31,9 +33,21 @@ def setup_harbor_stream_api(s) =
|
|||
], data=json.stringify(data))
|
||||
end
|
||||
|
||||
def on_list(~protocol, ~data, ~headers, uri) =
|
||||
data = [
|
||||
("ids", stream_api_streams)
|
||||
]
|
||||
http.response(protocol=protocol, code=200, headers=[
|
||||
("content-type","application/json"),
|
||||
], data=json.stringify(data))
|
||||
end
|
||||
|
||||
stream_api_streams = list.add(s.id(), stream_api_streams)
|
||||
|
||||
harbor.http.register(port=stream_api_port, method="POST", "/streams/#{s.id()}/start", on_start)
|
||||
harbor.http.register(port=stream_api_port, method="POST", "/streams/#{s.id()}/stop", on_stop)
|
||||
harbor.http.register(port=stream_api_port, method="GET", "/streams/#{s.id()}", on_info)
|
||||
harbor.http.register(port=stream_api_port, method="GET", "/streams/", on_list)
|
||||
|
||||
s
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue