Add support for plugin REST endpoints without view names
With this change it is possible to bind REST endpoints in plugins with empty view names: @Override protected void configure() { install(new RestApiModule() { @Override protected void configure() { delete(REVISION_KIND).to(HelloWorldAction.class); } }); } So defined endpoint can be accessed in two ways: with and without plugin namespace: DELETE /changes/1/revisions/1/ DELETE /changes/1/revisions/1/cookbook~ The last case is important to support because UiActions always prefix the view name with the plugin name. Change-Id: Ifd32fd7f33edcc7fcf763cdd780fb0a95e111519
This commit is contained in:
@@ -788,8 +788,12 @@ public class RestApiServlet extends HttpServlet {
|
||||
|
||||
List<String> p = splitProjection(projection);
|
||||
if (p.size() == 2) {
|
||||
String viewname = p.get(1);
|
||||
if (Strings.isNullOrEmpty(viewname)) {
|
||||
viewname = "/";
|
||||
}
|
||||
RestView<RestResource> view =
|
||||
views.get(p.get(0), method + "." + p.get(1));
|
||||
views.get(p.get(0), method + "." + viewname);
|
||||
if (view != null) {
|
||||
return new ViewData(p.get(0), view);
|
||||
}
|
||||
|
Reference in New Issue
Block a user