mirror of
https://github.com/gusaul/grpcox.git
synced 2025-05-06 07:25:36 +00:00
metadata implemented
This commit is contained in:
parent
2e3a588a8f
commit
f0c3ab2a2d
0
.idea/.gitignore
vendored
Normal file
0
.idea/.gitignore
vendored
Normal file
8
.idea/grpcox.iml
Normal file
8
.idea/grpcox.iml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
.idea/misc.xml
Normal file
6
.idea/misc.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="JavaScriptSettings">
|
||||||
|
<option name="languageLevel" value="ES6" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/grpcox.iml" filepath="$PROJECT_DIR$/.idea/grpcox.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
115
.idea/workspace.xml
Normal file
115
.idea/workspace.xml
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="11088c68-2e78-4a74-8eb3-020c776c2476" name="Default Changelist" comment="">
|
||||||
|
<change beforePath="$PROJECT_DIR$/core/resource.go" beforeDir="false" afterPath="$PROJECT_DIR$/core/resource.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/handler/handler.go" beforeDir="false" afterPath="$PROJECT_DIR$/handler/handler.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/index/css/style.css" beforeDir="false" afterPath="$PROJECT_DIR$/index/css/style.css" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/index/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/index/index.html" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/index/js/style.js" beforeDir="false" afterPath="$PROJECT_DIR$/index/js/style.js" afterDir="false" />
|
||||||
|
</list>
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="GOROOT" path="/usr/local/go" />
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="GoLibraries">
|
||||||
|
<option name="indexEntireGoPath" value="false" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectId" id="1ezC4Mc8DuAguAGt2dCH4SS4lx7" />
|
||||||
|
<component name="ProjectViewState">
|
||||||
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
|
<option name="showLibraryContents" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent">
|
||||||
|
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||||
|
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||||
|
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||||
|
<property name="go.import.settings.migrated" value="true" />
|
||||||
|
<property name="go.sdk.automatically.set" value="true" />
|
||||||
|
<property name="go.tried.to.enable.integration.vgo.integrator" value="true" />
|
||||||
|
<property name="last_opened_file_path" value="$USER_HOME$" />
|
||||||
|
<property name="nodejs_package_manager_path" value="npm" />
|
||||||
|
</component>
|
||||||
|
<component name="RunManager">
|
||||||
|
<configuration name="go build github.com/gusaul/grpcox" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="grpcox" />
|
||||||
|
<working_directory value="$PROJECT_DIR$" />
|
||||||
|
<kind value="PACKAGE" />
|
||||||
|
<filePath value="$PROJECT_DIR$/grpcox.go" />
|
||||||
|
<package value="github.com/gusaul/grpcox" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<recent_temporary>
|
||||||
|
<list>
|
||||||
|
<item itemvalue="Go Build.go build github.com/gusaul/grpcox" />
|
||||||
|
</list>
|
||||||
|
</recent_temporary>
|
||||||
|
</component>
|
||||||
|
<component name="TaskManager">
|
||||||
|
<task active="true" id="Default" summary="Default task">
|
||||||
|
<changelist id="11088c68-2e78-4a74-8eb3-020c776c2476" name="Default Changelist" comment="" />
|
||||||
|
<created>1595314841140</created>
|
||||||
|
<option name="number" value="Default" />
|
||||||
|
<option name="presentableId" value="Default" />
|
||||||
|
<updated>1595314841140</updated>
|
||||||
|
</task>
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
<option name="version" value="2" />
|
||||||
|
</component>
|
||||||
|
<component name="VgoProject">
|
||||||
|
<integration-enabled>true</integration-enabled>
|
||||||
|
</component>
|
||||||
|
<component name="WindowStateProjectService">
|
||||||
|
<state x="418" y="215" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1595315075588">
|
||||||
|
<screen x="0" y="34" width="1920" height="1046" />
|
||||||
|
</state>
|
||||||
|
<state x="418" y="215" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.34.1920.1046/1920.0.1920.1080@0.34.1920.1046" timestamp="1595315075588" />
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.0.bottom" timestamp="1595319271612">
|
||||||
|
<screen x="0" y="34" width="1920" height="1046" />
|
||||||
|
</state>
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.0.bottom/0.34.1920.1046/1920.0.1920.1080@0.34.1920.1046" timestamp="1595319271612" />
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.0.center" timestamp="1595319271612">
|
||||||
|
<screen x="0" y="34" width="1920" height="1046" />
|
||||||
|
</state>
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.0.center/0.34.1920.1046/1920.0.1920.1080@0.34.1920.1046" timestamp="1595319271612" />
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.0.left" timestamp="1595319271612">
|
||||||
|
<screen x="0" y="34" width="1920" height="1046" />
|
||||||
|
</state>
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.0.left/0.34.1920.1046/1920.0.1920.1080@0.34.1920.1046" timestamp="1595319271612" />
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.0.right" timestamp="1595319271612">
|
||||||
|
<screen x="0" y="34" width="1920" height="1046" />
|
||||||
|
</state>
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.0.right/0.34.1920.1046/1920.0.1920.1080@0.34.1920.1046" timestamp="1595319271612" />
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.1.bottom" timestamp="1595319271613">
|
||||||
|
<screen x="0" y="34" width="1920" height="1046" />
|
||||||
|
</state>
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.1.bottom/0.34.1920.1046/1920.0.1920.1080@0.34.1920.1046" timestamp="1595319271613" />
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.1.center" timestamp="1595319271613">
|
||||||
|
<screen x="0" y="34" width="1920" height="1046" />
|
||||||
|
</state>
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.1.center/0.34.1920.1046/1920.0.1920.1080@0.34.1920.1046" timestamp="1595319271613" />
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.1.left" timestamp="1595319271613">
|
||||||
|
<screen x="0" y="34" width="1920" height="1046" />
|
||||||
|
</state>
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.1.left/0.34.1920.1046/1920.0.1920.1080@0.34.1920.1046" timestamp="1595319271613" />
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.1.right" timestamp="1595319271613">
|
||||||
|
<screen x="0" y="34" width="1920" height="1046" />
|
||||||
|
</state>
|
||||||
|
<state width="1870" height="247" key="GridCell.Tab.1.right/0.34.1920.1046/1920.0.1920.1080@0.34.1920.1046" timestamp="1595319271613" />
|
||||||
|
<state width="960" height="523" key="XDebugger.FullValuePopup" timestamp="1595317727666">
|
||||||
|
<screen x="0" y="34" width="1920" height="1046" />
|
||||||
|
</state>
|
||||||
|
<state width="960" height="523" key="XDebugger.FullValuePopup/0.34.1920.1046/1920.0.1920.1080@0.34.1920.1046" timestamp="1595317727666" />
|
||||||
|
<state x="652" y="235" width="615" height="644" key="find.popup" timestamp="1595318929817">
|
||||||
|
<screen x="0" y="34" width="1920" height="1046" />
|
||||||
|
</state>
|
||||||
|
<state x="652" y="235" width="615" height="644" key="find.popup/0.34.1920.1046/1920.0.1920.1080@0.34.1920.1046" timestamp="1595318929817" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -184,13 +184,15 @@ func (r *Resource) Describe(symbol string) (string, string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke - invoking gRPC function
|
// Invoke - invoking gRPC function
|
||||||
func (r *Resource) Invoke(ctx context.Context, symbol string, in io.Reader) (string, time.Duration, error) {
|
func (r *Resource) Invoke(ctx context.Context, symbol string, in io.Reader, metadata []string) (string, time.Duration, error) {
|
||||||
err := r.openDescriptor()
|
err := r.openDescriptor()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", 0, err
|
return "", 0, err
|
||||||
}
|
}
|
||||||
defer r.closeDescriptor()
|
defer r.closeDescriptor()
|
||||||
|
|
||||||
|
r.headers = metadata
|
||||||
|
|
||||||
// because of grpcurl directly fmt.Printf on their invoke function
|
// because of grpcurl directly fmt.Printf on their invoke function
|
||||||
// so we stub the Stdout using os.Pipe
|
// so we stub the Stdout using os.Pipe
|
||||||
backUpStdout := os.Stdout
|
backUpStdout := os.Stdout
|
||||||
|
|
|
@ -221,8 +221,12 @@ func (h *Handler) invokeFunction(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
md := r.Header.Get("metadata")
|
||||||
|
|
||||||
|
mds := strings.Split(md, ",")
|
||||||
|
|
||||||
// get param
|
// get param
|
||||||
result, timer, err := res.Invoke(context.Background(), funcName, r.Body)
|
result, timer, err := res.Invoke(context.Background(), funcName, r.Body, mds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeError(w, err)
|
writeError(w, err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -11,6 +11,7 @@ body {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
}
|
}
|
||||||
.custom-pretty {
|
.custom-pretty {
|
||||||
|
height: 500px;
|
||||||
border:none!important;
|
border:none!important;
|
||||||
}
|
}
|
||||||
.custom-control-label:hover {
|
.custom-control-label:hover {
|
||||||
|
@ -200,4 +201,4 @@ circle {
|
||||||
transform: scaleY(1.0);
|
transform: scaleY(1.0);
|
||||||
-webkit-transform: scaleY(1.0);
|
-webkit-transform: scaleY(1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,9 @@
|
||||||
|
|
||||||
<div class="row other-elem" id="body-request" style="display: none">
|
<div class="row other-elem" id="body-request" style="display: none">
|
||||||
<div class="col-md-7">
|
<div class="col-md-7">
|
||||||
|
<input type="text" class="form-control" id="server-metadata" placeholder="gRPC Server Metadata: key1: value1, key2; value2...">
|
||||||
|
<br>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body schema-body">
|
|
||||||
<pre id="editor2"></pre>
|
|
||||||
</div>
|
|
||||||
<div class="card-body schema-body">
|
<div class="card-body schema-body">
|
||||||
<pre id="editor"></pre>
|
<pre id="editor"></pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,8 +3,6 @@ var target, use_tls, editor;
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
let cachedTarget = localStorage.getItem("server_target")
|
let cachedTarget = localStorage.getItem("server_target")
|
||||||
|
|
||||||
console.log(cachedTarget !== "undefined")
|
|
||||||
|
|
||||||
if (cachedTarget !== "undefined") {
|
if (cachedTarget !== "undefined") {
|
||||||
document.getElementById('server-target').value = cachedTarget;
|
document.getElementById('server-target').value = cachedTarget;
|
||||||
}
|
}
|
||||||
|
@ -93,6 +91,7 @@ $('#select-service').change(function(){
|
||||||
global: true,
|
global: true,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
success: function(res){
|
success: function(res){
|
||||||
|
console.log(res)
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
alert(res.error);
|
alert(res.error);
|
||||||
return;
|
return;
|
||||||
|
@ -151,7 +150,9 @@ $('#invoke-func').click(function(){
|
||||||
if (func == "") {
|
if (func == "") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var body = editor.getValue();
|
var body = editor.getValue();
|
||||||
|
var metadata = $('#server-metadata').val();
|
||||||
var button = $(this).html();
|
var button = $(this).html();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "server/"+target+"/function/"+func+"/invoke",
|
url: "server/"+target+"/function/"+func+"/invoke",
|
||||||
|
@ -159,6 +160,9 @@ $('#invoke-func').click(function(){
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: body,
|
data: body,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
|
headers: {
|
||||||
|
metadata: metadata
|
||||||
|
},
|
||||||
success: function(res){
|
success: function(res){
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
alert(res.error);
|
alert(res.error);
|
||||||
|
@ -187,6 +191,7 @@ function generate_editor(content) {
|
||||||
editor.setValue(content);
|
editor.setValue(content);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#editor").html(content);
|
$("#editor").html(content);
|
||||||
editor = ace.edit("editor");
|
editor = ace.edit("editor");
|
||||||
editor.setOptions({
|
editor.setOptions({
|
||||||
|
|
Loading…
Reference in New Issue
Block a user