]> gitweb.factorcode.org Git - factor.git/commitdiff
cgi: cleaner looking without parens.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 7 Feb 2017 00:22:07 +0000 (16:22 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 7 Feb 2017 00:22:07 +0000 (16:22 -0800)
extra/cgi/cgi-tests.factor
extra/cgi/cgi.factor

index 8c535bd077547b24f11de0582709b05b1cb9edf6..287768ff6883d3fc9b06882c69c4b1e005788f1f 100644 (file)
@@ -3,15 +3,15 @@
 
 USING: cgi cgi.private kernel linked-assocs tools.test ;
 
-{ LH{ } } [ "" (query-string) ] unit-test
+{ LH{ } } [ "" query-string ] unit-test
 
 { LH{ { "a" { "1" } } { "b" { "2" } } } }
-[ "a=1&b=2" (query-string) ] unit-test
+[ "a=1&b=2" query-string ] unit-test
 
 { LH{ { "a" { "1" } } { "b" { "2" "3" } } } }
-[ "a=1&b=2&b=3" (query-string) ] unit-test
+[ "a=1&b=2&b=3" query-string ] unit-test
 
-{ LH{ } "text/html" } [ "text/html" (content-type) ] unit-test
+{ LH{ } "text/html" } [ "text/html" content-type ] unit-test
 
 { LH{ { "charset" { "utf-8" } } } "text/html" }
-[ "text/html; charset=utf-8" (content-type) ] unit-test
+[ "text/html; charset=utf-8" content-type ] unit-test
index 585051f0fefee833787a4973465d9d81bb013fc4..5e93827579add12fac3c867001f33baf76e155bb 100644 (file)
@@ -9,32 +9,32 @@ IN: cgi
 
 <PRIVATE
 
-: (query-string) ( string -- assoc )
+: query-string ( string -- assoc )
     query>assoc [ nip ] assoc-filter [
         [ [ CHAR: \s = ] trim ]
         [ dup string? [ 1array ] when ] bi*
     ] assoc-map ;
 
 : parse-get ( -- assoc )
-    "QUERY_STRING" os-env "" or (query-string) ;
+    "QUERY_STRING" os-env "" or query-string ;
 
-: (content-type) ( string -- params media/type )
+: content-type ( string -- params media/type )
     ";" split unclip [
-        [ LH{ } clone ] [ first (query-string) ] if-empty
+        [ LH{ } clone ] [ first query-string ] if-empty
     ] dip ;
 
-: (multipart) ( -- assoc )
+: multipart ( -- assoc )
     "multipart unsupported" throw ;
 
-: (urlencoded) ( -- assoc )
+: urlencoded ( -- assoc )
     "CONTENT_LENGTH" os-env [ string>number ] [ 0 ] if*
     read [ "" ] [ "&" append ] if-empty
-    "QUERY_STRING" os-env [ append ] when* (query-string) ;
+    "QUERY_STRING" os-env [ append ] when* query-string ;
 
 : parse-post ( -- assoc )
-    "CONTENT_TYPE" os-env "" or (content-type) {
-       { "multipart/form-data"               [ (multipart) ] }
-       { "application/x-www-form-urlencoded" [ (urlencoded) ] }
+    "CONTENT_TYPE" os-env "" or content-type {
+       { "multipart/form-data"               [ multipart ] }
+       { "application/x-www-form-urlencoded" [ urlencoded ] }
        [ drop parse-get ]
    } case nip ;