This commit is contained in:
@@ -11,6 +11,7 @@ import java.util.*;
|
|||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import org.redkale.convert.json.JsonConvert;
|
import org.redkale.convert.json.JsonConvert;
|
||||||
import org.redkale.net.http.*;
|
import org.redkale.net.http.*;
|
||||||
|
import org.redkale.service.Service;
|
||||||
import org.redkale.source.*;
|
import org.redkale.source.*;
|
||||||
import org.redkale.util.*;
|
import org.redkale.util.*;
|
||||||
|
|
||||||
@@ -23,11 +24,11 @@ import org.redkale.util.*;
|
|||||||
*
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
*/
|
*/
|
||||||
public class ApiDocs extends HttpBaseServlet {
|
public class ApiDocsService extends DefaultRestServlet implements Service {
|
||||||
|
|
||||||
private final Application app; //Application全局对象
|
private final Application app; //Application全局对象
|
||||||
|
|
||||||
public ApiDocs(Application app) {
|
public ApiDocsService(Application app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +197,7 @@ public class ApiDocs extends HttpBaseServlet {
|
|||||||
if (doctemplate.isFile() && doctemplate.canRead()) {
|
if (doctemplate.isFile() && doctemplate.canRead()) {
|
||||||
in = new FileInputStream(doctemplate);
|
in = new FileInputStream(doctemplate);
|
||||||
}
|
}
|
||||||
if (in == null) in = ApiDocs.class.getResourceAsStream("apidoc-template.html");
|
if (in == null) in = ApiDocsService.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(), "apidoc.html"));
|
FileOutputStream outhtml = new FileOutputStream(new File(app.getHome(), "apidoc.html"));
|
||||||
@@ -204,8 +205,4 @@ public class ApiDocs extends HttpBaseServlet {
|
|||||||
outhtml.close();
|
outhtml.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void authenticate(int moduleid, int actionid, HttpRequest request, HttpResponse response, HttpServlet next) throws IOException {
|
|
||||||
next.execute(request, response);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -431,7 +431,7 @@ public final class Application {
|
|||||||
}
|
}
|
||||||
} else if ("APIDOC".equalsIgnoreCase(new String(bytes))) {
|
} else if ("APIDOC".equalsIgnoreCase(new String(bytes))) {
|
||||||
try {
|
try {
|
||||||
new ApiDocs(application).run();
|
new ApiDocsService(application).run();
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
buffer.put("APIDOC OK".getBytes());
|
buffer.put("APIDOC OK".getBytes());
|
||||||
buffer.flip();
|
buffer.flip();
|
||||||
@@ -476,7 +476,7 @@ public final class Application {
|
|||||||
final Application application = Application.create(true);
|
final Application application = Application.create(true);
|
||||||
application.init();
|
application.init();
|
||||||
application.start();
|
application.start();
|
||||||
new ApiDocs(application).run();
|
new ApiDocsService(application).run();
|
||||||
logger.info("APIDOC OK");
|
logger.info("APIDOC OK");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user