deskjet is an interactive HTTP utility written in Erlang to make API testing and HTTPS calls easier. It supports TLS certificates, JSON file requests, and repeated synchronous or asynchronous execution.
- Supports HTTP methods:
GET,POST,PATCH,PUT,DELETE - Send files as JSON request bodies
- Loop execution with
loop(synchronous) andloop_async(concurrent) - Works with secure HTTPS connections (SSL/TLS via
inetsandssl) - Returns are normalized as
{ok, Body}or{error, Reason}
-
Clone or copy the
deskjet_http.erlfile into your project directory. -
Compile using the Erlang shell:
1> c(deskjet_http). {ok, deskjet_http}
-
Start required libraries:
2> deskjet_http:start(). ok
This library requires a .pem file for HTTPS validation.
You can get the cacert.pem file from:
👉 https://curl.se/docs/caextract.html
Save the file as ../cert/cert.pem (or adjust the path in the code).
deskjet_http:get("https://example.com").deskjet_http:post("https://api.com/endpoint", "{"key":"value"}").deskjet_http:patch_with_file("https://api.com/update", "body.json").deskjet_http:perform("https://example.com", "{"key":"value"}", "post").deskjet_http:perform_with_file("https://example.com", "body.json", "put").deskjet_http:loop(10, fun() -> io:format("Test~n") end).deskjet_http:loop_async(10, fun() -> io:format("Test Async~n") end).start/0: Initializesinetsandsslget/1,post/2,patch/2,put/2,delete/1: Basic HTTP methods*_with_file/2: Reads file and sends its content as request bodyperform/1..3: Simplified method interfaceloop/2,loop_async/2: Repeats a function multiple times (sync or async)
- Teichmuller – [email protected]