Skip to content

Make HTTP requests from inside WASM in Extism PDK for .Net . Devcontainer.

License

Notifications You must be signed in to change notification settings

wasm-outbound-http-examples/extism-dotnet-pdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Use Extism PDK for .Net to send HTTP(s) requests from inside WASM

This devcontainer is configured to provide you a DotNet SDK 8.0 and wasi-sdk 20.0.

Open in GitHub Codespaces

Instructions for this devcontainer

Tested with Extism .NET PDK v1.0.3, Extism CLI v1.5.1.

Preparation

  1. Open this repo in devcontainer, e.g. using Github Codespaces. Type or copy/paste following commands to devcontainer's terminal.

  2. Install the WASI workload:

dotnet workload install wasi-experimental
  1. Generate WASI-enabled .Net project:
dotnet new wasiconsole -o HTTPRequestingPlugin
  1. cd into that project's directory:
cd HTTPRequestingPlugin
  1. Add Extism PDK dependency to project:
dotnet add package Extism.Pdk
  1. Copy HTTP example source code into project's folder to replace a generated one:
cp ../Program.cs . 

Building

  1. Compile the example:
dotnet build

Build process creates 25M-sized HTTPRequestingPlugin/bin/Debug/net8.0/wasi-wasm/AppBundle/HTTPRequestingPlugin.wasm bundle.

Test with Extism CLI

For testing purposes, you can invoke functions from Extism plugins with Extism CLI.

  1. Install Extism CLI from Github releases:
wget https://github.com/extism/cli/releases/download/v1.5.1/extism-v1.5.1-linux-amd64.tar.gz -O /tmp/extism.tar.gz
tar -xzf /tmp/extism.tar.gz -C /tmp ; mv /tmp/extism .

And now you have extism binary in current folder.

  1. Run default function (it's _start) from extism plugin with CLI, allowing outbound connections to all hosts:
./extism call ./bin/Debug/net8.0/wasi-wasm/AppBundle/HTTPRequestingPlugin.wasm _start --allow-host '*' --wasi

Finish

Perform your own experiments if desired.


This devcontainer is based on dev-wasm/dev-wasm-dotnet.

Created for (wannabe-awesome) list