Browse Source

fixes to restful (simplier argument scheme)

Jaromil 4 years ago
parent
commit
e70e31f5b6
1 changed files with 13 additions and 14 deletions
  1. 13 14
      zuper

+ 13 - 14
zuper

@@ -365,20 +365,21 @@ EOF
365 365
     zmodload zsh/net/tcp
366 366
 
367 367
     function restful.put() {
368
-        # $1 = hostname[:port][/path] (default port: 8500) (default path /v1/kv)
369
-        # $2 = key
370
-        # $3 = value
368
+        # $1 = hostname
369
+        # $2 = port
370
+        # $3 = path
371
+        # $4 = key
372
+        # $5 = value
371 373
 
372 374
         fn "restful.put $*"
373 375
 
374 376
         # to check if the http service is running is up to the caller
375 377
 
376 378
         _host=${1} # ip address
377
-        _port=${_host[(ws@:@)2]:-8500}
378
-        _path=${_path[(ws@:@)3]:/v1/kv}
379
-        _host=${_host[(ws@:@)1]}
380
-        _k="$2" # key name
381
-        _v="$3" # value
379
+        _port=${2}
380
+        _path=${3}
381
+        _k="$4" # key name
382
+        _v="$5" # value
382 383
 
383 384
         req=(_host _k _v)
384 385
         ckreq || return $?
@@ -428,12 +429,10 @@ EOF
428 429
     restful.get() {
429 430
         fn "restful.get $*"
430 431
 
431
-
432
-        _host=${1} # ip address
433
-        _port=${_host[(ws@:@)2]:-8500}
434
-        _path=${_path[(ws@:@)3]:/v1/kv}
435
-        _host=${_host[(ws@:@)1]}
436
-        _k=$2 # key name
432
+        _host=${1}
433
+        _port=${2}
434
+        _path=${3}
435
+        _k=$4 # key name
437 436
 
438 437
         req=(_host _k)
439 438
         ckreq || return $?