]> gitweb.factorcode.org Git - factor.git/commitdiff
github: fix json.http duplication
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 18 Apr 2023 20:16:10 +0000 (13:16 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 18 Apr 2023 20:16:10 +0000 (13:16 -0700)
basis/json/http/authors.txt [deleted file]
basis/json/http/http.factor [deleted file]
extra/github/github.factor

diff --git a/basis/json/http/authors.txt b/basis/json/http/authors.txt
deleted file mode 100644 (file)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/basis/json/http/http.factor b/basis/json/http/http.factor
deleted file mode 100644 (file)
index a28406d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-! Copyright (C) 2023 Doug Coleman.
-! See https://factorcode.org/license.txt for BSD license.
-USING: http.client json kernel ;
-IN: json.http
-
-: json-get* ( endpoint -- res json ) http-get* ?json> ;
-: json-post* ( post-data endpoint -- res json ) http-post* ?json> ;
-: json-put* ( post-data endpoint -- res json ) http-put* ?json> ;
-: json-patch* ( patch-data endpoint -- res json ) http-patch* ?json> ;
-: json-delete* ( endpoint -- res json ) http-delete* ?json> ;
-
-: json-get ( endpoint -- json ) http-get nip ?json> ;
-: json-post ( post-data endpoint -- json ) http-post nip ?json> ;
-: json-put ( post-data endpoint -- json ) http-put nip ?json> ;
-: json-patch ( patch-data endpoint -- json ) http-patch nip ?json> ;
-: json-delete ( endpoint -- json ) http-delete nip ?json> ;
index cfb6b97614479a6295d77840cab66d9c0ff18cb0..7f5c03dc6e709e0c58107099067a668524b4e0e5 100644 (file)
@@ -1,8 +1,11 @@
 ! Copyright (C) 2017 Doug Coleman.
 ! See https://factorcode.org/license.txt for BSD license.
+
 USING: accessors assocs assocs.extras calendar.parser cli.git
-formatting hashtables io.pathnames json json.http kernel math
-math.order namespaces.extras sequences sorting urls ;
+formatting hashtables http.client io.pathnames json json.http
+kernel math math.order namespaces.extras sequences sorting urls
+;
+
 IN: github
 
 ! Github API Docs: https://docs.github.com/en/rest
@@ -23,21 +26,11 @@ SYMBOL: github-token
     github-username required >>username
     github-token required >>password ;
 
-: github-get* ( url -- res json ) >github-url json-get* ;
-: github-post* ( post-data url -- res json ) [ ?>json ] [ >github-url ] bi* json-post* ;
-: github-put* ( post-data url -- res json ) [ ?>json ] [ >github-url ] bi* json-put* ;
-: github-patch* ( post-data url -- res json ) [ ?>json ] [ >github-url ] bi* json-patch* ;
-: github-delete* ( url -- res json ) >github-url json-delete* ;
-
-! 204 is ok, 404 is not
-: code-ok? ( response -- code ) code>> 204 = ; inline
-: github-get-code ( url -- json ) github-get* drop code-ok? ;
-
-: github-get ( url -- json ) >github-url json-get ;
-: github-post ( post-data url -- json ) [ ?>json ] [ >github-url ] bi* json-post ;
-: github-put ( post-data url -- json ) [ ?>json ] [ >github-url ] bi* json-put ;
-: github-patch ( post-data url -- json ) [ ?>json ] [ >github-url ] bi* json-patch ;
-: github-delete ( url -- json ) >github-url json-delete ;
+: github-get ( url -- json ) >github-url http-get-json nip ;
+: github-post ( post-data url -- json ) [ ?>json ] [ >github-url ] bi* http-post-json nip ;
+: github-put ( post-data url -- json ) [ ?>json ] [ >github-url ] bi* http-put-json nip ;
+: github-patch ( post-data url -- json ) [ ?>json ] [ >github-url ] bi* http-patch-json nip ;
+: github-delete ( url -- json ) >github-url http-delete-json nip ;
 
 ! type is one of { "orgs" "users" }
 : map-github-pages ( base-url params param-string -- seq )
@@ -87,7 +80,7 @@ SYMBOL: github-token
     "/search/code?q=%s+language:factor" sprintf github-get ;
 
 : check-enabled-vulnerability-alerts ( owner repo -- json )
-    "/repos/%s/%s/vulnerability-alerts" sprintf github-get-code ;
+    "/repos/%s/%s/vulnerability-alerts" sprintf github-get ;
 
 : enable-vulnerability-alerts ( owner repo -- json )
     [ f ] 2dip
@@ -135,7 +128,7 @@ SYMBOL: github-token
     "/repos/%s/%s/pulls/%d/files" sprintf map-github-pages-100 ;
 
 : pull-request-merged? ( owner repo n -- res )
-    "/repos/%s/%s/pulls/%d/merge" sprintf github-get-code ;
+    "/repos/%s/%s/pulls/%d/merge" sprintf github-get ;
 
 ! H{ { "commit_title" "oh wow" } { "commit_message" "messaged123" } { "merge_method" "merge|squash|rebase" } { "sha" "0c001" } }
 : merge-pull-request ( assoc owner repo n -- res )
@@ -180,7 +173,7 @@ SYMBOL: github-token
 : get-branch ( owner repo branch -- json ) "/repos/%s/%s/branches/%s" sprintf github-get ;
 : post-rename-branch ( owner repo branch new-name -- json )
     "new-name" associate -roll
-    "/repos/%s/%s/branches/%s/rename" sprintf >github-url json-post ;
+    "/repos/%s/%s/branches/%s/rename" sprintf github-post ;
 
 : get-my-issues ( -- json ) "/issues" github-get ;
 : get-my-org-issues ( org -- json ) "/orgs/%s/issues" sprintf github-get ;