1
0
mirror of https://github.com/gusaul/grpcox.git synced 2024-12-26 02:40:10 +00:00

Compare commits

..

No commits in common. "f240d0494ec1945483a85387c77eecc609aebd5a" and "8534ee1dc1e8ebb1ccc15aae173469759981c63e" have entirely different histories.

6 changed files with 5 additions and 45 deletions

View File

@ -137,11 +137,6 @@ func (g *GrpCox) Extend(host string) {
g.activeConn.extend(host, g.maxLifeConn)
}
// SetReflectHeaders sets grpcox reflection headers
func (g *GrpCox) SetReflectHeaders(headers ...string) {
g.reflectHeaders = headers
}
func (g *GrpCox) dial(ctx context.Context, target string, plainText bool) (*grpc.ClientConn, error) {
dialTime := 10 * time.Second
ctx, cancel := context.WithTimeout(ctx, dialTime)

View File

@ -285,14 +285,8 @@ func (r *Resource) AddProtos(protos []Proto) error {
protoPath := filepath.Join(BasePath, r.clientConn.Target())
err := os.MkdirAll(protoPath, 0777)
if os.IsExist(err) {
err = os.RemoveAll(protoPath)
if err != nil {
return err
}
os.RemoveAll(protoPath)
err = os.MkdirAll(protoPath, 0777)
if err != nil {
return err
}
} else if err != nil {
return err
}

View File

@ -60,7 +60,7 @@ func Test_prepareImport(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := prepareImport(tt.args.proto); !reflect.DeepEqual(got, tt.want) {
if got := prepareImport(tt.args.proto, ""); !reflect.DeepEqual(got, tt.want) {
t.Errorf("prepareImport() = %v, want %v",
string(got),
string(tt.want))

View File

@ -70,26 +70,6 @@ func (h *Handler) getLists(w http.ResponseWriter, r *http.Request) {
useTLS, _ := strconv.ParseBool(r.Header.Get("use_tls"))
restart, _ := strconv.ParseBool(r.FormValue("restart"))
// treat metadata as reflection headers
metadataHeader := r.Header.Get("Metadata")
metadataArr := strings.Split(metadataHeader, ",")
// construct array of strings with "key: value" form to be used in the reflection headers
var metadata []string
var metadataStr string
for i, m := range metadataArr {
i += 1
if isEven := i%2 == 0; isEven {
metadataStr = metadataStr + m
metadata = append(metadata, metadataStr)
metadataStr = ""
continue
}
metadataStr = fmt.Sprintf("%s:", m)
}
h.g.SetReflectHeaders(metadata...)
res, err := h.g.GetResource(context.Background(), host, !useTLS, restart)
if err != nil {
writeError(w, err)
@ -250,8 +230,8 @@ func (h *Handler) invokeFunction(w http.ResponseWriter, r *http.Request) {
var metadataStr string
for i, m := range metadataArr {
i += 1
if isEven := i%2 == 0; isEven {
metadataStr = metadataStr + m
if isEven := i % 2 == 0; isEven {
metadataStr = metadataStr+m
metadata = append(metadata, metadataStr)
metadataStr = ""
continue

View File

@ -231,7 +231,7 @@
<script type="text/javascript" src="js/popper.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/mdb.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.1/ace.js"></script>
<script type="text/javascript" src="js/db.js"></script>
<script type="text/javascript" src="js/style.js"></script>

View File

@ -17,12 +17,6 @@ $('#get-services').click(function(){
use_tls = "true"
}
// use metadata if there is any
ctxArr = [];
$(".ctx-metadata-input-field").each(function(index, val){
ctxArr.push($(val).text())
});
// determine whether the proto connection will use local proto or not
const use_proto = $('#local-proto').is(":checked");
@ -57,9 +51,6 @@ $('#get-services').click(function(){
beforeSend: function(xhr){
$('#choose-service').hide();
xhr.setRequestHeader('use_tls', use_tls);
if(ctxUse) {
xhr.setRequestHeader('Metadata', ctxArr);
}
$(this).html("Loading...");
show_loading();
},