WebAssembly for Proxies (Golang host implementation)

Overview

WebAssembly for Proxies (GoLang host implementation)

The GoLang implementation for proxy-wasm, enabling developer to run proxy-wasm extensions in Go.

Run Example

  • build and run host
cd example
go run .
  • send http request
curl http://127.0.0.1:2045/
  • host log
receive request /
print header from server host, User-Agent -> [curl/7.64.1]
print header from server host, Accept -> [*/*]
[http_wasm_example.cc:33]::onRequestHeaders() print from wasm, onRequestHeaders, context id: 2
[http_wasm_example.cc:38]::onRequestHeaders() print from wasm, Accept -> */*
[http_wasm_example.cc:38]::onRequestHeaders() print from wasm, User-Agent -> curl/7.64.1

references

Issues
  • Updates to latest go and wasmer

    Updates to latest go and wasmer

    Since I was here, I figured I'd bump the libraries. Nice that the example works!

    ## Build it
    $ (cd example; go build .)
    
    ## Ensure the linked libraries are there
    $ otool -L example/example
    example/example:
    	@rpath/libwasmer.dylib (compatibility version 0.0.0, current version 0.0.0)
    	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1858.112.0)
    	/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 60158.100.133)
    	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)
    
    $ du -k example/example 
    10512	example/example
    
    $ du -k vendor/github.com/wasmerio/wasmer-go/wasmer/packaged/lib/darwin-amd64/libwasmer.dylib 
    10404	vendor/github.com/wasmerio/wasmer-go/wasmer/packaged/lib/darwin-amd64/libwasmer.dylib
    
    ## try it
    $ (cd example; ./example)
    receive request /
    print header from server host, User-Agent -> [curl/7.79.1]
    print header from server host, Accept -> [*/*]
    [http_wasm_example.cc:33]::onRequestHeaders() print from wasm, onRequestHeaders, context id: 2
    [http_wasm_example.cc:38]::onRequestHeaders() print from wasm, Accept -> */*
    [http_wasm_example.cc:38]::onRequestHeaders() print from wasm, User-Agent -> curl/7.79.1
    

    PS if the intention is to keep floor go 1.14, definitely wazero won't work as we follow Go's support policy, and even if we didn't 1.14 is too far back.

    First-time contributor size/XXL cla:no cla:yes 
    opened by codefromthecrypt 8
  • go get mosn.io/proxy-wasm-go-host/proxywasm/common is failing

    go get mosn.io/proxy-wasm-go-host/proxywasm/common is failing

    I am trying to use this module in my proxy code, while I am running go get I get the following error - #go get mosn.io/proxy-wasm-go-host/proxywasm/common
    #go get: module mosn.io/[email protected] found (v0.1.0), but does not contain package mosn.io/proxy-wasm-go-host/proxywasm/common

    opened by sanfern 4
  • Not able to add header element.

    Not able to add header element.

    I am trying to add a header element to the request OnHttpRequestHeaders. It's not working or an error. Sample call - proxywasm.AddHttpRequestHeader("Debug", "1"), After this call context return back to the caller no instruction are executed.

    opened by sanfern 3
  • change foreign call param type from string to byte[]

    change foreign call param type from string to byte[]

    for function call, []byte is more generic than string

    reference: https://github.com/tetratelabs/proxy-wasm-go-sdk/blob/98ee1a9ebc5e1d32a8c044611acab87b4340393f/proxywasm/hostcall.go#L85

    opened by zhenjunMa 1
  • When call ProxyOnRequestHeaders get wrong action

    When call ProxyOnRequestHeaders get wrong action

    action

    cd example and replace the wasm file to new file which handles HTTP headers like this. Then go run . run the example.

    expected behaviour

    If the header hit, Action::Pause will be returned from wasm side. ActionPause will be returned by the function ProxyOnRequestHeaders.

    actual behaviour

    Regardless of whether the expected header appears. ActionContinue will be returned by the function ProxyOnRequestHeaders

    about the code

    I noticed that the action ProxyOnRequestHeaders returned is actually from CallWasmFunction, and res is ignored.

    Whether action should be ignored, the value of res should be converted into action format and returned. And what is a.Imports.Wait() actually do, is there any example for it?

    opened by Taction 4
  • Imports/exports don't match expected Proxy-Wasm ABI versions.

    Imports/exports don't match expected Proxy-Wasm ABI versions.

    Hello!

    It was pointed out to me (see: https://github.com/proxy-wasm/proxy-wasm-rust-sdk/issues/104) that Proxy-Wasm Go Host doesn't expose all Proxy-Wasm ABI v0.1.0 hostcalls.

    Looking at the code, neither imports nor exports match the specification, e.g. host exports proxy_dispatch_http_call and imports proxy_on_plugin_start, but those don't exists in any of the existing versions (ABI v0.1.0, v0.2.0 or v0.2.1).

    I believe that the source of the confusion might be the work-in-progress specification for vNEXT in proxy-wasm/spec, although even that doesn't define proxy_on_plugin_start, so it's unclear to me what's the source for your v1 and v2.

    Note that there is no documention for either ABI v0.1.0, v0.2.0 or v0.2.1, so the code in Envoy and Proxy-Wasm SDKs is effectively the specification for those versions.

    opened by PiotrSikora 3
Owner
MOSN
The Cloud Native Proxy for Edge or Service Mesh
MOSN
Go compiler for small places. Microcontrollers, WebAssembly, and command-line tools. Based on LLVM.

TinyGo - Go compiler for small places TinyGo is a Go compiler intended for use in small places such as microcontrollers, WebAssembly (Wasm), and comma

TinyGo 11k Jun 30, 2022
WebAssembly interop between Go and JS values.

vert Package vert provides WebAssembly interop between Go and JS values. Install GOOS=js GOARCH=wasm go get github.com/norunners/vert Examples Hello W

null 73 Jun 22, 2022
🐹🕸️ WebAssembly runtime for Go

Wasmer Go Website • Docs • Slack Channel A complete and mature WebAssembly runtime for Go based on Wasmer. Features Easy to use: The wasmer API mimics

Wasmer 2.1k Jun 23, 2022
🐹🕸️ WebAssembly runtime for Go

Wasmer Go Website • Docs • Slack Channel A complete and mature WebAssembly runtime for Go based on Wasmer. Features Easy to use: The wasmer API mimics

Wasmer 2.1k Jul 1, 2022
A package to build progressive web apps with Go programming language and WebAssembly.

Go-app is a package for building progressive web apps (PWA) with the Go programming language (Golang) and WebAssembly (Wasm). Shaping a UI is done by

Maxence Charriere 6.2k Jul 1, 2022
A package to build progressive web apps with Go programming language and WebAssembly.

Go-app is a package for building progressive web apps (PWA) with the Go programming language (Golang) and WebAssembly (Wasm). Shaping a UI is done by

Maxence Charriere 6.2k Jun 26, 2022
Vugu: A modern UI library for Go+WebAssembly (experimental)

Vugu: A modern UI library for Go+WebAssembly (experimental)

Vugu 4.4k Jul 4, 2022
WebAssembly runtime for wasmer-go

gowasmer When compiling Go to WebAssembly, the Go compiler assumes the WebAssembly is going to run in a JavaScript environment. Hence a wasm_exec.js f

mattn 87 Jun 18, 2022
A template project to demonstrate how to run WebAssembly functions as sidecar microservices in dapr

Live Demo 1. Introduction DAPR is a portable, event-driven runtime that makes it easy for any developer to build resilient, stateless and stateful app

Second State 121 Jun 21, 2022
Tiny, blazing fast WebAssembly compute

Sat, the tiny WebAssembly compute module Sat (as in satellite) is an experiment, and isn't ready for production use. Please try it out and give feedba

Suborbital 278 Jul 2, 2022
WebAssembly Lightweight Javascript Framework in Go (AngularJS Inspired)

Tango Lightweight WASM HTML / Javascript Framework Intro WebAssembly is nice, Go on the web is nice, so I ported Tangu to Go and WebAssembly. Tangu is

enimatek 4 Jun 8, 2022
Running a Command line tool written in Go on browser with WebAssembly

Running a command line tool written in Go on browser with WebAssembly This repo contains code/assets from the article Files: . ├── article.md

wcchoi 79 Jul 3, 2022
This library provides WebAssembly capability for goja Javascript engine

This module provides WebAssembly functions into goja javascript engine.

YC-L 1 Jan 10, 2022
A Brainfuck to WebAssembly compiler written in Go.

brainfuck2wasm A Brainfuck to WebAssembly compiler written in Go. I am writing this compiler for a Medium article. When I complete the compiler, I'll

Luke I. Wilson 2 Jun 6, 2022
Dom - A Go API for different Web APIs for WebAssembly target

Go DOM binding (and more) for WebAssembly This library provides a Go API for dif

Denys Smirnov 455 Jun 16, 2022
wazero: the zero dependency WebAssembly runtime for Go developers

wazero: the zero dependency WebAssembly runtime for Go developers WebAssembly is a way to safely run code compiled in other languages. Runtimes execut

Tetrate Labs 1.7k Jul 4, 2022
⚙️ Concept of Golang HTML render engine with frontend components and dynamic behavior

An HTML render engine concept that brings frontend-like components experience to the server side with native html/template on steroids. Supports any s

Yurii Zinets 503 Jun 13, 2022
Live views and components for golang

live Real-time user experiences with server-rendered HTML in Go. Inspired by and borrowing from Phoenix LiveViews. Live is intended as a replacement f

Josh Fyne 423 Jun 25, 2022
A WASM Filter for Envoy Proxy written in Golang

envoy-proxy-wasm-filter-golang A WASM Filter for Envoy Proxy written in Golang Build tinygo build -o optimized.wasm -scheduler=none -target=wasi ./mai

Emre Savcı 6 May 11, 2022