https://github.com/dev-formata-io/stof-http
Stof HTTP library.
https://github.com/dev-formata-io/stof-http
Last synced: 3 months ago
JSON representation
Stof HTTP library.
- Host: GitHub
- URL: https://github.com/dev-formata-io/stof-http
- Owner: dev-formata-io
- License: apache-2.0
- Created: 2025-01-04T18:58:02.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-01-23T18:51:06.000Z (3 months ago)
- Last Synced: 2025-01-23T19:06:53.800Z (3 months ago)
- Language: Rust
- Size: 27.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stof HTTP
Stof HTTP library. Adding this library to your Stof document allows you to make HTTP requests.## Example
Here is an example of using this library in Stof.``` rust
fn example(): str {
let url = "https://restcountries.com/v3.1/name/germany";
// Using a response object, we are telling the document to call header_import using the responses 'content-type' as a format,
// parsing the response into this object. The object can be created like so, or be an already created obj in the document somewhere.
let obj = new {};
let resp = HTTP.get(url, obj);
// resp is in the form (content type (str), headers (vec), body (blob))
// return resp[2] as str; // This would convert the blob body to a string using utf-8, returning the entire response body
let first = obj.field[0];
return `${first.altSpellings[1]} has an area of ${first.area}`; // returns 'Federal Republic of Germany has an area of 357114'
}
```