diff options
| author | 2023-03-26 18:24:13 -0400 | |
|---|---|---|
| committer | 2023-03-26 18:24:13 -0400 | |
| commit | 8018b1717278ec5a792977270610fcacd82bba3c (patch) | |
| tree | 745f6c9a85bbe16f89404c8a8cdb92195b5660ca | |
| parent | janet: fix mime data filename missing handle ref (diff) | |
meta: update readme and project metadata
| -rw-r--r-- | README.md | 55 | ||||
| -rw-r--r-- | project.janet | 5 |
2 files changed, 51 insertions, 9 deletions
@@ -4,15 +4,53 @@ Janet Curl (secretly Jean Curl) A libcurl easy API wrapper for Janet. It's divided into two components: `jurl-native`, which holds the low level C interfacing, and the high level `jurl` janet wrapper. -`jurl-native` is relatively feature-complete and is now mostly in maintenance mode. -Potential improvements are: -* gate additional features behind version checks -* implement the (very) few curl_easy things still left out (mostly things that I can't think of a sane way to represent) +`jurl-native` is mostly feature complete. +If something you depend on is missing, and you have a good idea on how to represent it in Janet, let me know in the issues. -`jurl` is under active construction. +`jurl`'s core functionality is complete. +There are still some utility functions for convenience to be written, but it's perfectly usable as it is. + +For examples of the various APIs, see the tests! +P.S. There are no tests yet, soon though. + +## Installation +This wraps around libcurl, and as such needs libcurl (library and headers for building) installed. +Tested on linux and macos. + +## Caveats +Not all features are gated behind version flags, patches welcome. +A few features are not implemented, grep for "not implemented" and "SKIP". +I'm open to implementing what's left, but it's generally very niche things, such as ioctl callbacks. ## Jurl -A higher level API that's currently in construction. +`jurl` is a requests-style API, but more complete. +For the main chunk of docs, see `jurl/init.janet`'s `request` symbol documentation. + +A few basic examples. +Get with a query: +```janet +(request {:url "https://pie.dev/get" + :query {:a "b" + :c "d"}}) +# -> {:body @"..." :error :ok :handle <jurl> :status 200} +``` + +A post with multipart mime (including file uploads): +```janet +(request {:url "https://pie.dev/post" + :body [{:name "field name" + :filename "remote.file" # this is what makes it a file upload + :data [:file "local.file"]}]}) +``` + +A post with json: +```janet +(request {:url "https://pie.dev/post" + :body (json/encode {:a "b" + :c "d"}) + :headers {:content-type "application/json"}) +# -> {:body @"..." :error :ok :handle <jurl> :status 200} +``` ## Jurl-Native `jurl-native` attempts to implement as much of libcurl's easy API in as direct a manner as possible. @@ -22,6 +60,7 @@ For example, `CURLOPT_TCP_FASTOPEN` becomes `:tcp-fastopen`. Enums (and bitmap members) are translated using a prefix notation. For example, `CURLPROXY_HTTP` becomes `:proxy/http`. +Ones that are extremely common are not prefixed, such as various `:auth/` keys. -Bitmaps are translates back and forth using indexables (arrays and tuples). -For example, `CURLAUTH_BASIC | CURLAUTH_DIGEST` becomes `[:auth/basic :auth/digest]`. +Bitmaps are translated back and forth using indexables (arrays and tuples). +For example, `CURLAUTH_BASIC | CURLAUTH_DIGEST` becomes `[basic digest]`. diff --git a/project.janet b/project.janet index 995783c..fe2ed8d 100644 --- a/project.janet +++ b/project.janet @@ -1,6 +1,9 @@ (declare-project :name "jurl" - :description "Janet cUrl") + :description "Janet cUrl" + :author "Chloe Kudryavtsev <toast@bunkerlabs.net>" + :license "Unlicense" + :repo "https://github.com/CosmicToast/jurl.git") (declare-native :name "jurl/native" |
