mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Update endpoints and docs
This commit is contained in:
parent
aeb8827e30
commit
be3f62dd10
@ -28,4 +28,4 @@ def base_url():
|
|||||||
|
|
||||||
def base_ws_uri():
|
def base_ws_uri():
|
||||||
"""Base websocket uri."""
|
"""Base websocket uri."""
|
||||||
return 'ws://{host}:{port}/'.format(**config['wsserver'])
|
return 'ws://{host}:{port}'.format(**config['wsserver'])
|
||||||
|
@ -6,6 +6,7 @@ from flask_restful import Resource
|
|||||||
import bigchaindb
|
import bigchaindb
|
||||||
from bigchaindb.web.views.base import base_url, base_ws_uri
|
from bigchaindb.web.views.base import base_url, base_ws_uri
|
||||||
from bigchaindb import version
|
from bigchaindb import version
|
||||||
|
from bigchaindb.web.websocket_server import EVENTS_ENDPOINT
|
||||||
|
|
||||||
|
|
||||||
class RootIndex(Resource):
|
class RootIndex(Resource):
|
||||||
@ -30,7 +31,7 @@ class RootIndex(Resource):
|
|||||||
class ApiV1Index(Resource):
|
class ApiV1Index(Resource):
|
||||||
def get(self):
|
def get(self):
|
||||||
api_root = base_url() + 'api/v1/'
|
api_root = base_url() + 'api/v1/'
|
||||||
websocket_root = base_ws_uri() + 'api/v1/'
|
websocket_root = base_ws_uri() + EVENTS_ENDPOINT
|
||||||
docs_url = [
|
docs_url = [
|
||||||
'https://docs.bigchaindb.com/projects/server/en/v',
|
'https://docs.bigchaindb.com/projects/server/en/v',
|
||||||
version.__version__,
|
version.__version__,
|
||||||
@ -43,6 +44,6 @@ class ApiV1Index(Resource):
|
|||||||
'statuses': api_root + 'statuses/',
|
'statuses': api_root + 'statuses/',
|
||||||
'transactions': api_root + 'transactions/',
|
'transactions': api_root + 'transactions/',
|
||||||
# TODO: The version should probably not be hardcoded
|
# TODO: The version should probably not be hardcoded
|
||||||
'streams_v1': websocket_root + 'streams/',
|
'streams_v1': websocket_root,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -26,7 +26,7 @@ from bigchaindb.events import EventTypes
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
POISON_PILL = 'POISON_PILL'
|
POISON_PILL = 'POISON_PILL'
|
||||||
EVENTS_ENDPOINT = '/api/v1/streams/'
|
EVENTS_ENDPOINT = '/api/v1/streams/valid_tx'
|
||||||
|
|
||||||
|
|
||||||
def _put_into_capped_queue(queue, value):
|
def _put_into_capped_queue(queue, value):
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
The WebSocket Event Stream API
|
The WebSocket Event Stream API
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
|
.. important::
|
||||||
|
The WebSocket Event Stream runs on a different port than the Web API. The
|
||||||
|
default port for the Web API is `9984`, while the one for the Event Stream
|
||||||
|
is `9985`.
|
||||||
|
|
||||||
BigchainDB provides real-time event streams over the WebSocket protocol with
|
BigchainDB provides real-time event streams over the WebSocket protocol with
|
||||||
the Event Stream API.
|
the Event Stream API.
|
||||||
|
|
||||||
@ -25,7 +30,7 @@ response contains a ``streams_<version>`` property in ``_links``::
|
|||||||
|
|
||||||
{
|
{
|
||||||
"_links": {
|
"_links": {
|
||||||
"streams_v1": "ws://example.com:9984/api/v1/streams/"
|
"streams_v1": "ws://example.com:9985/api/v1/streams/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +144,8 @@ def test_autoconfigure_read_both_from_file_and_env(monkeypatch, request):
|
|||||||
DATABASE_PORT = 4242
|
DATABASE_PORT = 4242
|
||||||
DATABASE_BACKEND = request.config.getoption('--database-backend')
|
DATABASE_BACKEND = request.config.getoption('--database-backend')
|
||||||
SERVER_BIND = '1.2.3.4:56'
|
SERVER_BIND = '1.2.3.4:56'
|
||||||
|
WSSERVER_HOST = '1.2.3.4'
|
||||||
|
WSSERVER_PORT = 57
|
||||||
KEYRING = 'pubkey_0:pubkey_1:pubkey_2'
|
KEYRING = 'pubkey_0:pubkey_1:pubkey_2'
|
||||||
|
|
||||||
file_config = {
|
file_config = {
|
||||||
@ -157,6 +159,8 @@ def test_autoconfigure_read_both_from_file_and_env(monkeypatch, request):
|
|||||||
'BIGCHAINDB_DATABASE_PORT': str(DATABASE_PORT),
|
'BIGCHAINDB_DATABASE_PORT': str(DATABASE_PORT),
|
||||||
'BIGCHAINDB_DATABASE_BACKEND': DATABASE_BACKEND,
|
'BIGCHAINDB_DATABASE_BACKEND': DATABASE_BACKEND,
|
||||||
'BIGCHAINDB_SERVER_BIND': SERVER_BIND,
|
'BIGCHAINDB_SERVER_BIND': SERVER_BIND,
|
||||||
|
'BIGCHAINDB_WSSERVER_HOST': WSSERVER_HOST,
|
||||||
|
'BIGCHAINDB_WSSERVER_PORT': WSSERVER_PORT,
|
||||||
'BIGCHAINDB_KEYRING': KEYRING})
|
'BIGCHAINDB_KEYRING': KEYRING})
|
||||||
|
|
||||||
import bigchaindb
|
import bigchaindb
|
||||||
@ -198,6 +202,10 @@ def test_autoconfigure_read_both_from_file_and_env(monkeypatch, request):
|
|||||||
'workers': None,
|
'workers': None,
|
||||||
'threads': None,
|
'threads': None,
|
||||||
},
|
},
|
||||||
|
'wsserver': {
|
||||||
|
'host': WSSERVER_HOST,
|
||||||
|
'port': WSSERVER_PORT,
|
||||||
|
},
|
||||||
'database': database,
|
'database': database,
|
||||||
'keypair': {
|
'keypair': {
|
||||||
'public': None,
|
'public': None,
|
||||||
|
@ -31,6 +31,6 @@ def test_api_v1_endpoint(client):
|
|||||||
'self': 'http://localhost/api/v1/',
|
'self': 'http://localhost/api/v1/',
|
||||||
'statuses': 'http://localhost/api/v1/statuses/',
|
'statuses': 'http://localhost/api/v1/statuses/',
|
||||||
'transactions': 'http://localhost/api/v1/transactions/',
|
'transactions': 'http://localhost/api/v1/transactions/',
|
||||||
'streams_v1': 'ws://localhost:9985/api/v1/streams/',
|
'streams_v1': 'ws://localhost:9985/api/v1/streams/valid_tx',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user