Merge "Add documentation for server-config plugin"
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serverconfig/HttpModule.java b/src/main/java/com/googlesource/gerrit/plugins/serverconfig/HttpModule.java
index e0695b1..1e79af7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serverconfig/HttpModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serverconfig/HttpModule.java
@@ -20,6 +20,6 @@
@Override
protected void configureServlets() {
filter("/*").through(HideFromNonAdmins.class);
- serve("/*").with(ServerConfigServlet.class);
+ serve("/etc/*", "/static/*").with(ServerConfigServlet.class);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serverconfig/ServerConfigServlet.java b/src/main/java/com/googlesource/gerrit/plugins/serverconfig/ServerConfigServlet.java
index f0007d5..d41dffb 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serverconfig/ServerConfigServlet.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serverconfig/ServerConfigServlet.java
@@ -186,7 +186,7 @@
}
private File configFile(HttpServletRequest req) {
- return new File(site_path, req.getPathInfo());
+ return new File(site_path, req.getServletPath() + req.getPathInfo());
}
private boolean isParent(File parent, File child) throws IOException {
diff --git a/src/main/resources/Documentation/about.md b/src/main/resources/Documentation/about.md
new file mode 100644
index 0000000..9d2496a
--- /dev/null
+++ b/src/main/resources/Documentation/about.md
@@ -0,0 +1,7 @@
+This plugin allows to change the content of Gerrit's configuration files via REST.
+
+Any configuration files under <site>/etc or <site>/static can be changed.
+
+A server restart may be needed for some changes to be taken into effect.
+
+Administrator privileges are required to use this plugin.
diff --git a/src/main/resources/Documentation/rest-api-server-config.md b/src/main/resources/Documentation/rest-api-server-config.md
new file mode 100644
index 0000000..5fb0d90
--- /dev/null
+++ b/src/main/resources/Documentation/rest-api-server-config.md
@@ -0,0 +1,63 @@
+@PLUGIN@ - /server-config/ REST API
+===================================
+
+This page describes the REST endpoints that are added by the @PLUGIN@
+plugin.
+
+Please also take note of the general information on the
+[REST API](../../../Documentation/rest-api.html).
+
+<a id="server-config-endpoints"> Server Config Endpoints
+------------------------------------------
+
+Get the content of a configuration file.
+
+### <a id="get-content"> Read File
+_GET /plugins/server-config/\{path\}_
+
+Read the content of a configuration file. Only Gerrit administrators are allowed
+to read the content of a configuration file.
+
+#### Request
+
+```
+ GET /plugins/server-config/etc/gerrit.config HTTP/1.0
+```
+
+As response the content of the configuration file `gerrit.config` is returned.
+
+#### Response
+
+```
+ HTTP/1.1 200 OK
+ Content-Type: application/octet-stream
+
+ [gerrit]
+ basePath = git
+ canonicalWebUrl = ...
+ ....
+```
+
+### <a id="write-content"> Write File
+_PUT /plugins/server-config/\{path\}_
+
+Update the content of a configuration file. Only Gerrit administrators are
+allowed to update the content of a configuration file. A server restart may be
+needed for some configuration changes to be taken into effect.
+
+#### Request
+
+```
+ PUT /plugins/server-config/etc/gerrit.config HTTP/1.0
+
+ [gerrit]
+ basePath = git
+ canonicalWebUrl = ...
+ ....
+```
+
+#### Response
+```
+ HTTP/1.1 204 No Content
+```
+