Commits

Tim van der Linden committed 3ecfcc2

Removed append and used filter from srfi-1 instead, updated to correct versionnumber in setup file.

Comments (0)

Files changed (2)

json-rpc-client.scm

   (json-rpc-server)
 
 (import chicken scheme)
-(use medea extras)
+(use medea extras srfi-1)
 
 ; Setup the custom error handlers
 (define (server-setup-arguments-error type expected given)
 	     (cond ((not (is-valid-method? method)) (server-setup-data-error "method" "can only be a string."))
 		   ((not (are-valid-params? params)) (server-setup-data-error "params" "can only be a vector or an alist."))
 		   (else
-		    (send-request (append (list (cons 'jsonrpc version))
-					  (list (cons 'method method))
-					  (if (null? params) '()
-					      (list (cons 'params (build-params params))))
-					  (list (cons 'id "1"))) ;ID is hardcoded, overkill to generate random ID, you can't handle more then one request/response at a time...or can you?
+		    (send-request (filter notnull? (list (cons 'jsonrpc version)
+							(cons 'method method)
+							(if (null? params) '()
+							    (cons 'params (build-params params)))
+							    (cons 'id "1"))) ;ID is hardcoded - can't handle more then one request at a time...or can we?
 				  input 
 				  output)))))))
 
+; Predicate for inverting the null? predicate
+(define (notnull? x)
+  (not (null? x)))
+
 ; Helper for building a vector or alist from the parameters if present
 (define (build-params params)    
     (if (keyword? (car params)) 
 ; Helper for building an alist
 (define (build-alist params)
     (if (null? params) 
-	(append '())
+	'()
 	(cons (cons (car params) (car (cdr params))) (build-alist (cdr (cdr params))))))
 
 ; Helper for building a vector
 (define (is-valid-method? method)
     (string? method))
 
-; Check if the params are a list (alist or vector) as defined in the spec
+; Check if the params are a list as defined in the spec
 (define (are-valid-params? params)
     (list? params)) ;Assumptions? Don't know if this check is enough (check for null (is also a list) or list)
 
 (install-extension
  'json-rpc
  '("json-rpc-client.so" "json-rpc-client.import.so")
- '((version "0.1")
+ '((version "0.1.3")
    (documentation "json-rpc.html")))