From 5e5bd043c60193a9368e8f393d42c011667565be Mon Sep 17 00:00:00 2001 From: Hannes Hansen Date: Sat, 22 Dec 2018 13:34:30 +0100 Subject: [PATCH] added possibility to define own ./well-known-core endpoint --- coapthon/layers/forwardLayer.py | 3 ++- coapthon/layers/requestlayer.py | 3 ++- coapthon/utils.py | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/coapthon/layers/forwardLayer.py b/coapthon/layers/forwardLayer.py index e36f68d..e4acc56 100644 --- a/coapthon/layers/forwardLayer.py +++ b/coapthon/layers/forwardLayer.py @@ -50,11 +50,12 @@ class ForwardLayer(object): :rtype : Transaction :return: the edited transaction """ + wkc_resource_is_defined = defines.DISCOVERY_URL in self._server.root path = str("/" + transaction.request.uri_path) transaction.response = Response() transaction.response.destination = transaction.request.source transaction.response.token = transaction.request.token - if path == defines.DISCOVERY_URL: + if path == defines.DISCOVERY_URL and not wkc_resource_is_defined: transaction = self._server.resourceLayer.discover(transaction) else: new = False diff --git a/coapthon/layers/requestlayer.py b/coapthon/layers/requestlayer.py index 0286b4c..e864436 100644 --- a/coapthon/layers/requestlayer.py +++ b/coapthon/layers/requestlayer.py @@ -52,11 +52,12 @@ class RequestLayer(object): :rtype : Transaction :return: the edited transaction with the response to the request """ + wkc_resource_is_defined = defines.DISCOVERY_URL in self._server.root path = str("/" + transaction.request.uri_path) transaction.response = Response() transaction.response.destination = transaction.request.source transaction.response.token = transaction.request.token - if path == defines.DISCOVERY_URL: + if path == defines.DISCOVERY_URL and not wkc_resource_is_defined: transaction = self._server.resourceLayer.discover(transaction) else: try: diff --git a/coapthon/utils.py b/coapthon/utils.py index 505054c..661d4ce 100644 --- a/coapthon/utils.py +++ b/coapthon/utils.py @@ -186,3 +186,6 @@ class Tree(object): def __delitem__(self, key): del self.tree[key] + + def __contains__(self, item): + return item in self.tree