Skip to content

Commit c09998b

Browse files
committed
Add more programming rest interface examples. Fix broken link.
1 parent 5635e13 commit c09998b

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

doc/rest.txt

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,48 @@ returns some data about the class::
12341234
Adding other endpoints (e.g. to allow an OPTIONS query against
12351235
``/data/issue/@schema``) is left as an exercise for the reader.
12361236

1237+
Redefine/move rest endpoints
1238+
============================
1239+
1240+
In addition to adding new endpoints, you can redefine existing
1241+
endpoints. Adding this as described above::
1242+
1243+
@Routing.route("/summary")
1244+
@_data_decorator
1245+
def summary2(self, input):
1246+
result = { "hello": "world" }
1247+
return 200, result
1248+
1249+
will return::
1250+
1251+
{
1252+
"data": {
1253+
"hello": "world"
1254+
}
1255+
}
1256+
1257+
1258+
In addition to overriding existing endpoints, you can move existing
1259+
endpoints to new locations. Adding::
1260+
1261+
@Routing.route("/data2/<:classname>")
1262+
def get_collection2(self, classname, input):
1263+
""" Remap existing function in rest.py to a new endpoint
1264+
1265+
Existing function is decorated with:
1266+
1267+
@Routing.route("/data/<:classname>")
1268+
@_data_decorator
1269+
1270+
so we need to drop @_data_decorator from this function since
1271+
we can't apply @_data_decorator twice.
1272+
"""
1273+
return self.get_collection(classname, input)
1274+
1275+
will move the response that normally happens at /rest/data/<class> to
1276+
/rest/data/<class>.
1277+
1278+
12371279
Controlling Access to Backend Data
12381280
==================================
12391281

@@ -1568,9 +1610,10 @@ a jwt to see if it's still valid using::
15681610
Final steps
15691611
^^^^^^^^^^^
15701612

1571-
See the `upgrading documentation`__ on how to regenerate an updated copy of
1572-
config.ini using roundup-admin. Then set the ``jwt_secret`` to at
1573-
least 32 characters (more is better up to 512 bits).
1613+
See the `upgrading directions`_ on how to use the ``updateconfig`` to
1614+
generate an updated copy of config.ini using roundup-admin. Then set
1615+
the ``jwt_secret`` to at least 32 characters (more is better up to 512
1616+
bits).
15741617

15751618
Writing an auditor that uses "db.user.get_roles" to see if the user
15761619
making the change has the ``user:timelog`` role, and then comparing

0 commit comments

Comments
 (0)