mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Add /blocks/{block_id} safety querystring
It didn't feel good letting users retrieve also invalid or undecided blocks in the /blocks/{block_id} endpoint. Hence, now a block can be evaluated by it's status. If block_id and status do not match, a 404 Not Found HTTP status code is returned. Per default, status is set to valid only.
This commit is contained in:
parent
8f7816d325
commit
8e91e14e86
@ -470,16 +470,23 @@ Statuses
|
|||||||
Blocks
|
Blocks
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
.. http:get:: /blocks/{block_id}
|
.. http:get:: /blocks/{block_id}?status={VALID|UNDECIDED|INVALID}
|
||||||
|
|
||||||
Get the block with the ID ``block_id``.
|
Get the block with the ID ``block_id``.
|
||||||
|
|
||||||
A block is only returned if it was labeled ``VALID`` or ``UNDECIDED`` and
|
.. note::
|
||||||
exists in the table ``bigchain``.
|
As ``status``'s default value is set to ``VALID``, only ``VALID`` blocks
|
||||||
|
will be returned by this endpoint. In case ``status=VALID``, but a block
|
||||||
|
that was labeled ``UNDECIDED`` or ``INVALID`` is requested by
|
||||||
|
``block_id``, this endpoint will return a ``404 Not Found`` status code
|
||||||
|
to warn the user. To check a block's status independently, use the
|
||||||
|
`Statuses endpoint <#get--statuses-tx_id|block_id>`_.
|
||||||
|
|
||||||
:param block_id: block ID
|
:param block_id: block ID
|
||||||
:type block_id: hex string
|
:type block_id: hex string
|
||||||
|
|
||||||
|
:query string status: Per default set to ``VALID``. One of ``VALID``, ``UNDECIDED`` or ``INVALID``.
|
||||||
|
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
@ -512,8 +519,9 @@ Blocks
|
|||||||
|
|
||||||
:resheader Content-Type: ``application/json``
|
:resheader Content-Type: ``application/json``
|
||||||
|
|
||||||
:statuscode 200: A block with that ID was found. Its status is either ``VALID`` or ``UNDECIDED``.
|
:statuscode 200: A block with that ID was found.
|
||||||
:statuscode 404: A block with that ID was not found.
|
:statuscode 400: The request wasn't understood by the server, e.g. just requesting ``/blocks`` without the ``block_id``.
|
||||||
|
:statuscode 404: A block with that ID and a certain ``status`` was not found.
|
||||||
|
|
||||||
.. http:get:: /blocks
|
.. http:get:: /blocks
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user