Skip to content

Commit

Permalink
Allow resources to hide from .well-known/core listing
Browse files Browse the repository at this point in the history
... by returning None in their `get_link_description()` method.

Closes: #53
  • Loading branch information
chrysn committed Mar 1, 2021
1 parent 7e60ddc commit 2c715c5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions aiocoap/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class Resource(_ExposesWellknownAttributes, interfaces.Resource):
Moreover, this class provides a ``get_link_description`` method as used by
.well-known/core to expose a resource's ``.ct``, ``.rt`` and ``.if_``
(alternative name for ``if`` as that's a Python keyword) attributes.
Details can be added by overriding the method to return a more
comprehensive dictionary, and resources can be hidden completely by
returning None.
"""

async def needs_blockwise_assembly(self, request):
Expand Down Expand Up @@ -400,6 +403,8 @@ def get_resources_as_linkheader(self):
details = resource.get_link_description()
else:
details = {}
if details is None:
continue
lh = Link('/' + '/'.join(path), **details)

links.append(lh)
Expand Down

0 comments on commit 2c715c5

Please sign in to comment.