Git Product home page Git Product logo

spin-teavm-example's Introduction

spin-teavm-example

TL;DR

./spin build
./spin up
./spin deploy

Intro

This is a example demonstrating how to use TeaVM-WASI, wit-bindgen, and Spin to build and run a simple stateless web service in Java, targetting WebAssembly

Prerequisites

On Ubuntu 22.04 x86_64, this should do the job:

sudo apt install openjdk-18-jdk maven curl
curl -L -O https://github.com/fermyon/spin/releases/download/v0.6.0/spin-v0.6.0-linux-amd64.tar.gz
tar xf spin-v0.6.0-linux-amd64.tar.gz
sudo cp spin /usr/local/bin/

Building, running, and testing

spin build
spin up &
curl http://localhost:3000

(Optional) Re-generate bindings

Prerequisites

  • Rust
  • A recent wit-bindgen (git commit 9609ca8 is known to work)
cargo install --git https://github.com/bytecodealliance/wit-bindgen \
    --rev 9609ca8daf2dadcb71082a1ad7ec86bbf0fbb5ef --locked wit-bindgen-cli

(Re-)generating the bindings

wit-bindgen guest teavm-java --export wit/spin-http.wit \
    --out-dir src/main/java/wit_spin_http/
wit-bindgen guest teavm-java --import wit/wasi-outbound-http.wit \
    --out-dir src/main/java/wit_wasi_outbound_http/

spin-teavm-example's People

Contributors

dicej avatar albertoimpl avatar

Stargazers

Juan Antonio Breña Moral avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.