use monaco editor

This commit is contained in:
pengfei.zhou
2019-08-14 20:07:36 +08:00
parent 8c2c55e7b8
commit d9eb9489b8
6 changed files with 70 additions and 14 deletions

View File

@@ -12,6 +12,7 @@ import com.github.penfeizhou.doric.DoricDriver;
import com.github.pengfeizhou.jscore.JSONBuilder;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.IOException;
import java.io.InputStream;
@@ -78,6 +79,34 @@ public class LocalServer extends NanoHTTPD {
return "{}";
}
});
commandMap.put("reload", new APICommand() {
@Override
public String name() {
return "reload";
}
@Override
public Object exec(IHTTPSession session) {
Map<String, String> files = new HashMap<>();
try {
session.parseBody(files);
} catch (Exception e) {
e.printStackTrace();
}
String id = session.getParms().get("id");
DoricContext doricContext = DoricContextManager.getContext(id);
if (doricContext != null) {
try {
JSONObject jsonObject = new JSONObject(files.get("postData"));
doricContext.reload(jsonObject.optString("script"));
} catch (Exception e) {
e.printStackTrace();
}
return "success";
}
return "fail";
}
});
}