π¦ ClawHub
Gcore FastEdge
by @geri4
Build and deploy WebAssembly applications to Gcore FastEdge edge computing platform. Use when creating, building, or deploying FastEdge HTTP apps with Rust S...
π‘ Examples
1. Create a new FastEdge app
Initialize a Rust project with the FastEdge SDK:
mkdir myapp && cd myapp
Create .cargo/config.toml:
[build]
target = "wasm32-wasip1"
Create Cargo.toml:
[package]
name = "myapp"
version = "0.1.0"
edition = "2021"[lib]
crate-type = ["cdylib"]
[dependencies]
fastedge = "0.2"
Create src/lib.rs:
use fastedge::{
body::Body,
http::{Request, Response, StatusCode, Error},
};#[fastedge::http]
fn main(_req: Request
) -> Result, Error> {
Response::builder()
.status(StatusCode::OK)
.header("content-type", "text/plain")
.body(Body::from("Hello from FastEdge!"))
}
2. Build the Wasm binary
Requires Rust and wasm32-wasip1 target:
rustup target add wasm32-wasip1
cargo build --release
Binary location: target/wasm32-wasip1/release/myapp.wasm
3. Deploy via CLI
Set your API key (get from https://accounts.gcore.com/account-settings/api-tokens):
export GCORE_API_KEY="your_api_token"
Upload binary:
curl -X POST \
'https://api.gcore.com/fastedge/v1/binaries/raw' \
-H 'accept: application/json' \
-H "Authorization: APIKey $GCORE_API_KEY" \
-H 'Content-Type: application/octet-stream' \
--data-binary '@./target/wasm32-wasip1/release/myapp.wasm'
Save the id from response (binary_id).
Create app:
curl -X POST \
'https://api.gcore.com/fastedge/v1/apps' \
-H 'accept: application/json' \
-H 'client_id: 0' \
-H "Authorization: APIKey $GCORE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"name": "my-app-name",
"binary": BINARY_ID,
"status": 1
}'
Your app will be at: https://my-app-name-XXXX.fastedge.app
TERMINAL
clawhub install gcore-fastedge