diff options
-rw-r--r-- | guix-data-service/web/query-parameters.scm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/guix-data-service/web/query-parameters.scm b/guix-data-service/web/query-parameters.scm index 45353b9..3140238 100644 --- a/guix-data-service/web/query-parameters.scm +++ b/guix-data-service/web/query-parameters.scm @@ -36,6 +36,7 @@ any-invalid-query-parameters? parse-query-parameters + query-parameters->string parse-datetime parse-result-limit)) @@ -110,6 +111,31 @@ (processor value)))))) accepted-query-parameters)) +(define (query-parameters->string query-parameters) + (define (value->text value) + (match value + (#f "") + ((? date? date) + (date->string date "~1 ~3")) + (other other))) + + (string-join + (concatenate + (map + (match-lambda + ((key . ($ <invalid-query-parameter>)) + '()) + ((key . value) + (list (simple-format #f "~A=~A" + key (value->text value)))) + ((key values ...) + (map (lambda (value) + (simple-format #f "~A=~A" + key (value->text value))) + values))) + query-parameters)) + "&")) + (define (parse-datetime s) (catch 'misc-error |