Skip to content
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

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.roastedroot.proxywasm.jaxrs;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

@Path("/http_headers")
public class HttpHeadersResource {

@GET
@NamedWasmPlugin("http_headers")
public String get() {
return "hello world";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.roastedroot.proxywasm.jaxrs;

import static io.restassured.RestAssured.given;
import static io.roastedroot.proxywasm.jaxrs.TestHelpers.EXAMPLES_DIR;
import static org.hamcrest.Matchers.equalTo;

import com.dylibso.chicory.wasm.Parser;
import io.quarkus.test.junit.QuarkusTest;
import io.roastedroot.proxywasm.StartException;
import jakarta.enterprise.inject.Produces;
import java.nio.file.Path;
import org.junit.jupiter.api.Test;

@QuarkusTest
public class HttpHeadersTest {

@Produces
public WasmPluginFactory create() throws StartException {
return () ->
WasmPlugin.builder()
.withName("http_headers")
.withPluginConfig("{\"header\": \"x-wasm-header\", \"value\": \"foo\"}")
.build(
Parser.parse(
Path.of(
EXAMPLES_DIR
+ "/go-examples/http_headers/main.wasm")));
}

@Test
public void testRequest() {
given().when()
.get("/http_headers")
.then()
.statusCode(200)
.header("x-proxy-wasm-go-sdk-example", "http_headers")
.header("x-wasm-header", "foo")
.body(equalTo("hello world"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.roastedroot.proxywasm.jaxrs;

public final class TestHelpers {
private TestHelpers() {}

public static final String EXAMPLES_DIR = "../proxy-wasm-java-host/src/test";
}