Skip to content

Repository files navigation

ft-sdk

Rust SDK for extending backend functionality of fastn using WASM modules.

docs.rs/ft-sdk

Note

This crate should only be used when compiled to wasm.


Example

// lib.rs// An http handler available at /<mountpoint>/hello-world/#[ft_sdk::processor]fnhello_world(path: ft_sdk::Path) -> ft_sdk::processor::Result{
ft_sdk::println!("params: {path}");// Return a JSON string as response. Complex json with `serde_json::json!`// or any Serializable struct is supported.
ft_sdk::processor::json("and this is coming from wasm!")}

Compile the rust project with target wasm32-unknown-unknown and copy the .wasm file into your fastn package.

You can then mount this module by adding the following to your FASTN.ftd file:

-- import: fastn
-- fastn.package: hello-world
-- fastn.url-mappings:
/wasm/* -> wasm+proxy://hello_world.wasm/*

Now any .ftd file can make request to /wasm/hello-world/ and it will be handled by the hello_world function in the wasm module:

-- import: fastn/processors as pr
-- ftd.text: this is in ftd file
-- ftd.text: $message
-- string message:
$processor$: pr.http
url: /wasm/hello-world/

See ./examples/ for more examples including form handling and interacting with database using the diesel crate.

Maintenance Note

Run scripts/check.sh before release.

ft-stripe

This project provides integration with Stripe HTTP APIs. It is based on the async-stripe project, with its own implementation of a Client to call Stripe APIs.

License

This project includes many source files copied from async-stripe. We acknowledge and are grateful to the developers of async-stripe for their contributions to open source.

Licensed under either of

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

2 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages