Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update ffi_hello_world template doc #139

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions templates/ffi_hello_world/TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ username: Invertase

This project shows how to integrate **Dart** with **Rust** using the [Foreign Function Interface](https://dart.dev/interop/c-interop) (FFI). The Rust code has to be compiled for the `x86_64` architecture to ensure compatibility with the Globe runtime.

## Bootstrap

Initialize the project using the command below

```shell
$ globe create -t ffi_hello_world
```

## Project Structure

```
Expand Down
5 changes: 4 additions & 1 deletion templates/ffi_hello_world/bin/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ String greetHuman(String name) {
void main(List<String> args) async {
final handler = Pipeline().addMiddleware(logRequests()).addHandler((request) {
final name = request.url.queryParameters['name'] ?? 'FFI Works 🚀';
return Response.ok(greetHuman(name));
return Response.ok(
greetHuman(name),
headers: {'Content-Type': 'text/plain'},
);
});

final port = int.parse(Platform.environment['PORT'] ?? '8080');
Expand Down
Loading