Commit 2b844713 authored by Guillaume Vandevelde's avatar Guillaume Vandevelde
Browse files

[rql_schema_holder] Setup new views to request the schema or its hash

parent 2a4743846642
......@@ -33,6 +33,7 @@ from cubicweb.web import RemoteCallFailed, DirectResponse
from cubicweb.web.controller import Controller
from cubicweb.web.views.urlrewrite import rgx_action, SchemaBasedRewriter
from cubicweb import Binary
from cubicweb_rqlcontroller.rql_schema_holder import RqlIOSchemaHolder
ARGRE = re.compile(r'__r(?P<ref>\d+)$')
......@@ -74,6 +75,18 @@ class match_request_content_type(ExpectedValuePredicate):
return header
class RqlIOSchemaController(Controller, RqlIOSchemaHolder):
__regid__ = 'rqlio_schema'
__select__ = match_http_method('GET', 'HEAD')
def publish(self, rset=None):
self._cw.set_content_type('application/json')
self._cw.add_header('Etag', self.get_schema_hash)
return json.dumps(
self.get_schema
).encode(self._cw.encoding)
class RqlIOController(Controller):
"""posted rql queries and arguments use the following pattern:
......@@ -167,6 +180,8 @@ class RqlIOController(Controller):
class RQLIORewriter(SchemaBasedRewriter):
rules = [
(re.compile('/rqlio/schema'),
rgx_action(controller='rqlio_schema')),
(re.compile('/rqlio/(?P<version>.+)$'),
rgx_action(controller='rqlio', formgroups=('version',))),
rgx_action(controller='rqlio', formgroups=('version',)))
]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment