This commit is contained in:
7
bin/apidoc.bat
Normal file
7
bin/apidoc.bat
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
|
||||||
|
SET APP_HOME=%~dp0
|
||||||
|
|
||||||
|
IF NOT EXIST "%APP_HOME%\conf\application.xml" SET APP_HOME=%~dp0..
|
||||||
|
|
||||||
|
java -DCMD=APIDOC -DAPP_HOME=%APP_HOME% -classpath %APP_HOME%\lib\* org.redkale.boot.Application
|
||||||
@@ -15,4 +15,4 @@ do
|
|||||||
done
|
done
|
||||||
export CLASSPATH=$CLASSPATH:$lib
|
export CLASSPATH=$CLASSPATH:$lib
|
||||||
echo "$APP_HOME"
|
echo "$APP_HOME"
|
||||||
java -DCMD=RESTDOC -DAPP_HOME="$APP_HOME" org.redkale.boot.Application
|
java -DCMD=APIDOC -DAPP_HOME="$APP_HOME" org.redkale.boot.Application
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
@ECHO OFF
|
|
||||||
|
|
||||||
SET APP_HOME=%~dp0
|
|
||||||
|
|
||||||
IF NOT EXIST "%APP_HOME%\conf\application.xml" SET APP_HOME=%~dp0..
|
|
||||||
|
|
||||||
java -DCMD=RESTDOC -DAPP_HOME=%APP_HOME% -classpath %APP_HOME%\lib\* org.redkale.boot.Application
|
|
||||||
@@ -17,11 +17,11 @@ import org.redkale.util.*;
|
|||||||
*
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
*/
|
*/
|
||||||
public class RestDocs extends HttpBaseServlet {
|
public class ApiDocs extends HttpBaseServlet {
|
||||||
|
|
||||||
private final Application app;
|
private final Application app;
|
||||||
|
|
||||||
public RestDocs(Application app) {
|
public ApiDocs(Application app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,18 +123,18 @@ public class RestDocs extends HttpBaseServlet {
|
|||||||
resultmap.put("servers", serverList);
|
resultmap.put("servers", serverList);
|
||||||
resultmap.put("types", typesmap);
|
resultmap.put("types", typesmap);
|
||||||
final String json = JsonConvert.root().convertTo(resultmap);
|
final String json = JsonConvert.root().convertTo(resultmap);
|
||||||
final FileOutputStream out = new FileOutputStream(new File(app.getHome(), "restdoc.json"));
|
final FileOutputStream out = new FileOutputStream(new File(app.getHome(), "apidoc.json"));
|
||||||
out.write(json.getBytes("UTF-8"));
|
out.write(json.getBytes("UTF-8"));
|
||||||
out.close();
|
out.close();
|
||||||
File doctemplate = new File(app.getHome(), "conf/restdoc-template.html");
|
File doctemplate = new File(app.getHome(), "conf/apidoc-template.html");
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
if (doctemplate.isFile() && doctemplate.canRead()) {
|
if (doctemplate.isFile() && doctemplate.canRead()) {
|
||||||
in = new FileInputStream(doctemplate);
|
in = new FileInputStream(doctemplate);
|
||||||
}
|
}
|
||||||
if (in == null) in = RestDocs.class.getResourceAsStream("restdoc-template.html");
|
if (in == null) in = ApiDocs.class.getResourceAsStream("apidoc-template.html");
|
||||||
String content = Utility.read(in).replace("${content}", json);
|
String content = Utility.read(in).replace("${content}", json);
|
||||||
in.close();
|
in.close();
|
||||||
FileOutputStream outhtml = new FileOutputStream(new File(app.getHome(), "restdoc.html"));
|
FileOutputStream outhtml = new FileOutputStream(new File(app.getHome(), "apidoc.html"));
|
||||||
outhtml.write(content.getBytes("UTF-8"));
|
outhtml.write(content.getBytes("UTF-8"));
|
||||||
outhtml.close();
|
outhtml.close();
|
||||||
}
|
}
|
||||||
@@ -388,16 +388,16 @@ public final class Application {
|
|||||||
buffer.flip();
|
buffer.flip();
|
||||||
channel.send(buffer, address);
|
channel.send(buffer, address);
|
||||||
}
|
}
|
||||||
} else if ("RESTDOC".equalsIgnoreCase(new String(bytes))) {
|
} else if ("APIDOC".equalsIgnoreCase(new String(bytes))) {
|
||||||
try {
|
try {
|
||||||
new RestDocs(application).run();
|
new ApiDocs(application).run();
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
buffer.put("RESTDOC OK".getBytes());
|
buffer.put("APIDOC OK".getBytes());
|
||||||
buffer.flip();
|
buffer.flip();
|
||||||
channel.send(buffer, address);
|
channel.send(buffer, address);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
buffer.put("RESTDOC FAIL".getBytes());
|
buffer.put("APIDOC FAIL".getBytes());
|
||||||
buffer.flip();
|
buffer.flip();
|
||||||
channel.send(buffer, address);
|
channel.send(buffer, address);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user