Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phoenixpinpoint/fido
Fido provides JS Fetch and Libcurl API bindings in C for use in WASM and Native Applications. Additionally Fido provides a simple Header, Request and, Response API
https://github.com/phoenixpinpoint/fido
c curl fetch fetch-api http libcurl rest wasm
Last synced: 2 months ago
JSON representation
Fido provides JS Fetch and Libcurl API bindings in C for use in WASM and Native Applications. Additionally Fido provides a simple Header, Request and, Response API
- Host: GitHub
- URL: https://github.com/phoenixpinpoint/fido
- Owner: phoenixpinpoint
- License: gpl-3.0
- Created: 2023-11-10T17:44:44.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-22T21:38:30.000Z (2 months ago)
- Last Synced: 2024-10-23T08:22:41.567Z (2 months ago)
- Topics: c, curl, fetch, fetch-api, http, libcurl, rest, wasm
- Language: C
- Homepage:
- Size: 175 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fido
Fido provides JS Fetch and libcurl API bindings in C for use in WASM. Additionally Fido provides a simple Header, Request and, Response API.## Installation & Running
### clibs Installation
Installing Fido is simple with clibs. This section assumes you have the deps folder added to your includ path.
```bash
clib install phoenixpinpoint/fido
```
Somewhere in your GCC Makefile/Buildpath:
```bash
-Ideps
```
In your C files:
```c
#include
```
### manual Installation
Although not recommended it is possible to install Fido without clibs. The general idea is below but mileage may vary.
```bash
#Create Deps Folder
mkdir deps
cd deps
#Add Deps and Fido
git clone https://github.com/clibs/buffer.git
git clone https://github.com/phoenixpinpoint/fido.git
#Update compiler
gcc ..-Ideps..-Ideps/fido/src
```
### compilation and testing
This section only applies for the project as a standalone. Compiling Fido as a standalone project with emscripten.
- Note: If you are running WASM/Emscripten tests you *MUST* be using a node version that supports the Fetch API.
```bash
make test
```
## Use
### Simple GET
In this example we make a simple GET to a Web Page.
```c
#includeint main()
{
//Note if all macros are left intact you can remove FIDO_
FIDO_HTTP_REQUEST *req = FIDO_CREATE_HTTP_REQUEST("https://google.com", NULL, NULL);
FIDO_HTTP_RESPONSE *res = FIDO_GET(req);//If the server response with 200 OK
if(res->response_code == 200)
{
printf("BODY: %s\n", res->body);
}
else {
printf("Some Error Occured.\n");
}
return 0;
}
```
### Simple POST
In this example we make a simple POST to a Web Page.
```c
#includeint main()
{
//Note if all macros are left intact you can remove FIDO_
FIDO_HEADER *contentType = FIDO_CREATE_HEADER("Content-Type", "application/json");
FIDO_HEADERLIST *headers = FIDO_CREATE_HEADER_LIST();
FIDO_ADD_HEADER(headers, contentType);
FIDO_HTTP_REQUEST *req = FIDO_CREATE_HTTP_REQUEST("https://example.com", headers, "{\"TEST\":\"VALUE\"}");
FIDO_HTTP_RESPONSE *res = FIDO_POST(req);//If the server response with 200 OK
if(res->response_code == 200)
{
printf("BODY: %s\n", res->body);
}
else {
printf("Some Error Occured.\n");
}
return 0;
}
```
## Additional Docs
All Documents are on this main repo so check out the other .md files.