https://github.com/albertoimpl/wasm-boot-hello
Spring boot calling WASM
https://github.com/albertoimpl/wasm-boot-hello
spring spring-boot wasm webassembly
Last synced: 11 months ago
JSON representation
Spring boot calling WASM
- Host: GitHub
- URL: https://github.com/albertoimpl/wasm-boot-hello
- Owner: Albertoimpl
- Created: 2022-02-07T09:56:23.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-15T11:15:30.000Z (almost 4 years ago)
- Last Synced: 2025-01-23T21:28:11.605Z (about 1 year ago)
- Topics: spring, spring-boot, wasm, webassembly
- Language: JavaScript
- Homepage:
- Size: 2.22 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spring boot and WebAssembly
Calling a simple sum function written in C from a .wasm file from a Spring Boot application using [wasmer-java](https://github.com/wasmerio/wasmer-java).
To run the project:
```shell
./gradlew bootRun
```
To call the function:
```shell
curl 'http://localhost:8080/sum?x=10&y=25'
```
Note that this needed to be added in `build.gradle`
```groovy
bootRun {
jvmArgs = ["-Dos.arch=amd64"]
}
```
To compile the sum function
```shell
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
```
```shell
emcc sum/sum.c -o sum/sum.js -s EXPORTED_FUNCTIONS='["_sum"]'
```
```shell
cp sum/sum.wasm src/main/resources/
```