Skip to content

Commit

Permalink
Merge pull request #33280 from elpaso/bugfix-gh33203-broken-link-on-s…
Browse files Browse the repository at this point in the history
…lash

Bugfix gh33203 broken link on slash
  • Loading branch information
elpaso committed Dec 8, 2019
2 parents 2672c74 + e1ea0f3 commit 341c85a
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 4 deletions.
9 changes: 9 additions & 0 deletions python/server/auto_generated/qgsserverogcapi.sip.in
Expand Up @@ -20,6 +20,15 @@ as instances of QgsServerOgcApiHandler.

.. code-block:: python

class Handler1(QgsServerOgcApiHandler):
"""A handler, see QgsServerOgcApiHandler for an example"""
...

h = Handler1()
api = QgsServerOgcApi(serverInterface(), "/api1", "apione", "A firs API", "1.0")
api.registerHandler(h)
server.serverInterface().serviceRegistry().registerApi(api)

.. versionadded:: 3.10
%End

Expand Down
32 changes: 32 additions & 0 deletions python/server/auto_generated/qgsserverogcapihandler.sip.in
Expand Up @@ -33,6 +33,38 @@ Optionally, override:
- contentTypes
- defaultContentType

.. code-block:: python

class Handler1(QgsServerOgcApiHandler):
"""Example handler"""

def path(self):
return QtCore.QRegularExpression("/handlerone")

def operationId(self):
return "handlerOne"

def summary(self):
return "First of its name"

def description(self):
return "The first handler ever"

def linkTitle(self):
return "Handler One Link Title"

def linkType(self):
return QgsServerOgcApi.data

def handleRequest(self, context):
"""Simple mirror: returns the parameters"""

params = self.values(context)
self.write(params, context)

def parameters(self, context):
return [QgsServerQueryStringParameter("value1", True, QgsServerQueryStringParameter.Type.Double, "a double value")]

.. versionadded:: 3.10
%End

Expand Down
9 changes: 9 additions & 0 deletions src/server/qgsserverogcapi.h
Expand Up @@ -32,6 +32,15 @@ class QgsServerOgcApiHandler;
*
* \code{.py}
*
* class Handler1(QgsServerOgcApiHandler):
* """A handler, see QgsServerOgcApiHandler for an example"""
* ...
*
* h = Handler1()
* api = QgsServerOgcApi(serverInterface(), "/api1", "apione", "A firs API", "1.0")
* api.registerHandler(h)
* server.serverInterface().serviceRegistry().registerApi(api)
*
* \endcode
*
* \since QGIS 3.10
Expand Down
34 changes: 34 additions & 0 deletions src/server/qgsserverogcapihandler.h
Expand Up @@ -52,6 +52,40 @@ class QgsServerApiContext;
* - contentTypes
* - defaultContentType
*
* \code{.py}
*
* class Handler1(QgsServerOgcApiHandler):
* """Example handler"""
*
* def path(self):
* return QtCore.QRegularExpression("/handlerone")
*
* def operationId(self):
* return "handlerOne"
*
* def summary(self):
* return "First of its name"
*
* def description(self):
* return "The first handler ever"
*
* def linkTitle(self):
* return "Handler One Link Title"
*
* def linkType(self):
* return QgsServerOgcApi.data
*
* def handleRequest(self, context):
* """Simple mirror: returns the parameters"""
*
* params = self.values(context)
* self.write(params, context)
*
* def parameters(self, context):
* return [QgsServerQueryStringParameter("value1", True, QgsServerQueryStringParameter.Type.Double, "a double value")]
*
*
* \endcode
*
* \since QGIS 3.10
*/
Expand Down
8 changes: 4 additions & 4 deletions src/server/services/wfs3/qgswfs3handlers.h
Expand Up @@ -176,7 +176,7 @@ class QgsWfs3CollectionsHandler: public QgsWfs3AbstractItemsHandler
void handleRequest( const QgsServerApiContext &context ) const override;

// QgsServerOgcApiHandler interface
QRegularExpression path() const override { return QRegularExpression( R"re(/collections(\.json|\.html)?$)re" ); }
QRegularExpression path() const override { return QRegularExpression( R"re(/collections(\.json|\.html|/)?$)re" ); }
std::string operationId() const override { return "describeCollections"; }
std::string summary() const override
{
Expand All @@ -203,7 +203,7 @@ class QgsWfs3DescribeCollectionHandler: public QgsWfs3AbstractItemsHandler
QgsWfs3DescribeCollectionHandler( );
void handleRequest( const QgsServerApiContext &context ) const override;

QRegularExpression path() const override { return QRegularExpression( R"re(/collections/(?<collectionId>[^/]+?)(\.json|\.html)?$)re" ); }
QRegularExpression path() const override { return QRegularExpression( R"re(/collections/(?<collectionId>[^/]+?)(\.json|\.html|/)?$)re" ); }
std::string operationId() const override { return "describeCollection"; }
std::string summary() const override { return "Describe the feature collection with ID {collectionId}."; }
std::string description() const override { return "Metadata about a feature collection."; }
Expand All @@ -222,7 +222,7 @@ class QgsWfs3CollectionsItemsHandler: public QgsWfs3AbstractItemsHandler
public:
QgsWfs3CollectionsItemsHandler( );
void handleRequest( const QgsServerApiContext &context ) const override;
QRegularExpression path() const override { return QRegularExpression( R"re(/collections/(?<collectionId>[^/]+)/items(\.geojson|\.json|\.html)?$)re" ); }
QRegularExpression path() const override { return QRegularExpression( R"re(/collections/(?<collectionId>[^/]+)/items(\.geojson|\.json|\.html|/)?$)re" ); }
std::string operationId() const override { return "getFeatures"; }
std::string summary() const override { return "Retrieve features of feature collection {collectionId}."; }
std::string description() const override
Expand Down Expand Up @@ -251,7 +251,7 @@ class QgsWfs3CollectionsFeatureHandler: public QgsWfs3AbstractItemsHandler
public:
QgsWfs3CollectionsFeatureHandler( );
void handleRequest( const QgsServerApiContext &context ) const override;
QRegularExpression path() const override { return QRegularExpression( R"re(/collections/(?<collectionId>[^/]+)/items/(?<featureId>[^/]+?)(\.json|\.geojson|\.html)?$)re" ); }
QRegularExpression path() const override { return QRegularExpression( R"re(/collections/(?<collectionId>[^/]+)/items/(?<featureId>[^/]+?)(\.json|\.geojson|\.html|/)?$)re" ); }
std::string operationId() const override { return "getFeature"; }
std::string description() const override { return "Retrieve a feature with ID {featureId} from the collection with ID {collectionId}; use content negotiation or specify a file extension to request HTML (.html or GeoJSON (.json)."; }
std::string summary() const override { return "Retrieve a single feature with ID {featureId} from the collection with ID {collectionId}."; }
Expand Down
8 changes: 8 additions & 0 deletions tests/src/python/test_qgsserver_api.py
Expand Up @@ -405,6 +405,11 @@ def test_wfs3_collections_content_type(self):
response = QgsBufferServerResponse()
self.server.handleRequest(request, response, project)
self.assertEqual(response.headers()['Content-Type'], 'text/html')
request = QgsBufferServerRequest('http://server.qgis.org/wfs3/collections')
request.setHeader('Accept', 'text/html')
response = QgsBufferServerResponse()
self.server.handleRequest(request, response, project)
self.assertEqual(response.headers()['Content-Type'], 'text/html')

def test_wfs3_collection_json(self):
"""Test WFS3 API collection"""
Expand Down Expand Up @@ -433,6 +438,9 @@ def test_wfs3_collection_html(self):
project.read(unitTestDataPath('qgis_server') + '/test_project_api.qgs')
request = QgsBufferServerRequest('http://server.qgis.org/wfs3/collections/testlayer%20èé.html')
self.compareApi(request, project, 'test_wfs3_collection_testlayer_èé.html')
request = QgsBufferServerRequest('http://server.qgis.org/wfs3/collections/testlayer%20èé/')
request.setHeader('Accept', 'text/html')
self.compareApi(request, project, 'test_wfs3_collection_testlayer_èé.html')

def test_wfs3_collection_items(self):
"""Test WFS3 API items"""
Expand Down

0 comments on commit 341c85a

Please sign in to comment.