From 6d75ad70fbb7ee4d05173a05f8b9aa8a4eb77b17 Mon Sep 17 00:00:00 2001 From: SnnSnn Date: Thu, 25 Mar 2021 15:11:11 +0300 Subject: [PATCH] Update echo example with step by step instructions (#32) * Update echo example with step by step instructions * Update extras example * Apply requested changes * Apply the second round of change requests --- echo/Cargo.lock | 28 ++--- echo/Cargo.toml | 6 +- echo/Makefile | 34 ++++++ echo/README.md | 232 +++++++++++++++++++++++++++++++++++++++- echo/docker-compose.yml | 12 +++ echo/manifest.yaml | 14 +++ echo/src/lib.rs | 34 +++--- extras/Cargo.lock | 2 +- extras/Cargo.toml | 4 +- extras/README.md | 106 ++++++++++++++++-- extras/manifest.yaml | 18 ++++ extras/src/lib.rs | 8 +- 12 files changed, 445 insertions(+), 53 deletions(-) create mode 100644 echo/Makefile create mode 100644 echo/docker-compose.yml create mode 100644 echo/manifest.yaml create mode 100644 extras/manifest.yaml diff --git a/echo/Cargo.lock b/echo/Cargo.lock index 5a32f50a..17073e4a 100644 --- a/echo/Cargo.lock +++ b/echo/Cargo.lock @@ -8,9 +8,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "byteorder" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cfg-if" @@ -71,18 +71,18 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ "proc-macro2", ] [[package]] name = "rmp" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f10b46df14cf1ee1ac7baa4d2fbc2c52c0622a4b82fa8740e37bc452ac0184f" +checksum = "4f55e5fa1446c4d5dd1f5daeed2a4fe193071771a2636274d0d7a3b082aa7ad6" dependencies = [ "byteorder", "num-traits", @@ -107,9 +107,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "serde" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" +checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" dependencies = [ "serde_derive", ] @@ -125,9 +125,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" +checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" dependencies = [ "proc-macro2", "quote", @@ -136,9 +136,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.62" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea1c6153794552ea7cf7cf63b1231a25de00ec90db326ba6264440fa08e31486" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ "itoa", "ryu", @@ -147,9 +147,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.60" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" +checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" dependencies = [ "proc-macro2", "quote", diff --git a/echo/Cargo.toml b/echo/Cargo.toml index 623996a4..f2bcf6b5 100644 --- a/echo/Cargo.toml +++ b/echo/Cargo.toml @@ -8,13 +8,13 @@ edition = "2018" crate-type = ["cdylib"] [dependencies] +serde = {version = "1.0.118", features = ["derive"]} +serde_json ="1.0.60" wapc-guest = "0.4.0" wasmcloud-actor-core = { version = "0.2.2", features = ["guest"] } wasmcloud-actor-http-server = { version = "0.1.1", features = ["guest"]} -serde_json ="1.0.60" -serde = {version = "1.0.118", features = ["derive"]} [profile.release] # Optimize for small code size -opt-level = "s" lto = true +opt-level = "s" diff --git a/echo/Makefile b/echo/Makefile new file mode 100644 index 00000000..00d45e09 --- /dev/null +++ b/echo/Makefile @@ -0,0 +1,34 @@ +COLOR ?= always # Valid COLOR options: {always, auto, never} +CARGO = cargo --color $(COLOR) +TARGET = target/wasm32-unknown-unknown +DEBUG = $(TARGET)/debug +RELEASE = $(TARGET)/release +KEYDIR ?= .keys +VERSION = $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[].version') + +.PHONY: all build check clean doc test update + +all: build + +build: + @$(CARGO) build + wash claims sign $(DEBUG)/echo.wasm -c wasmcloud:httpserver --name "echo" --ver $(VERSION) --rev 0 + +check: + @$(CARGO) check + +clean: + @$(CARGO) clean + +doc: + @$(CARGO) doc + +test: build + @$(CARGO) test + +update: + @$(CARGO) update + +release: + @$(CARGO) build --release + wash claims sign $(RELEASE)/echo.wasm -c wasmcloud:httpserver --name "echo" --ver $(VERSION) --rev 0 \ No newline at end of file diff --git a/echo/README.md b/echo/README.md index db536dcc..4a172db8 100644 --- a/echo/README.md +++ b/echo/README.md @@ -1,5 +1,233 @@ # Echo Example -This example is designed to illustrate a few simple aspects of coding an actor module with wasmCloud. The first shows how to respond to simple HTTP requests, but this sample also shows how to use `serde` for JSON serialization. +An actor is the smallest unit of deployable, portable compute within the wasmcloud ecosystem. -This actor module responds to all incoming HTTP requests by returning a JSON object describing the inbound request. +Actors are small WebAssembly modules that can handle messages delivered to them by the host runtime and can invoke functions on capability providers, provided they have been granted the appropriate privileges. + +Check out [https://wasmcloud.dev/reference/host-runtime/actors/](https://wasmcloud.dev/reference/host-runtime/actors/) for more. + +In this example our actor responds to all incoming HTTP requests by returning the HTTP request as a JSON object. + +We will have a two part tutorial, starting with running a precompiled actor stored in a remote OCI registry, then we will write our own actor and swap it with the remote one. We will use a manifest file to run our actor declaratively via `wasmcloud`. + +In the second part, we will spin up a NATS server and a local docker registry to store our WebAssembly module. We'll use the wasmcloud shell, `wash`, a feature-rich cli tool that provides an interactive REPL environment to run our actor and interact with it. + +## Running an echo server + +1. Please install `wasmcloud` and `wash` binaries if you do not have them installed already. `wasmcloud` will provide the runtime environment for our actor while `wash` will be used for development later in the tutorial: + + [https://wasmcloud.dev/overview/installation/](https://wasmcloud.dev/overview/installation/) + + ```bash + $ wasmcloud --version + $ wash --version + ``` + +2. Locate manifest.yaml file here in the project folder and run it with `--manifest` flag: + + ```bash + $ wasmcloud -m manifest.yaml + ``` + + Here are the contents of the file: + + ```bash + labels: + sample: "wasmcloud echo" + actors: + - "wasmcloud.azurecr.io/echo:0.2.0" + capabilities: + - image_ref: wasmcloud.azurecr.io/httpserver:0.11.1 + link_name: default + links: + - actor: ${ECHO_ACTOR:MBCFOPM6JW2APJLXJD3Z5O4CN7CPYJ2B4FTKLJUR5YR5MITIU7HD3WD5} + provider_id: "VAG3QITQQ2ODAOWB5TTQSDJ53XK3SHBEIFNK4AYJ5RKAX2UNSCAPHA5M" + contract_id: "wasmcloud:httpserver" + link_name: default + values: + PORT: 8080 + ``` + +3. Visit `http://localhost:8080` to see the result: + + ```bash + curl http://localhost:8080/ + ``` + + That is it, you are running a highly secure HTTP server powered by a WebAssembly module. + +4. Now lets build our own actor and swap with the remote one: + + ```bash + $ cargo build --release + ``` + +5. To be able to use it, we need to sign it: + + ```bash + $ wash claims sign ./target/wasm32-unknown-unknown/release/echo.wasm -c wasmcloud:httpserver --name "echo" --ver 0.2.2 + ``` + + Read more on the security aspects at https://wasmcloud.dev/reference/host-runtime/security/. + +6. Actors are signed with unique module keys, so the echo actor ID will be different for everyone. We'll need to inspect the actor to find its public key (module) for the next step: + + ```bash + $ wash claims inspect ./target/wasm32-unknown-unknown/release/echo_s.wasm + ``` + + This will output something like: + + ```bash + Account ACPVJRHMJ5GM2EOQWRPAQVKL75NBOCTZC52TAYPDCDA2GLXJ6TVJOPDN + Module MCUDTMOOZCVAM5EBNN4U3X2OGHNIY3BKPEW66HY4RTCYYVWXOE7ESVDQ + Expires never + Can Be Used immediately + Version 0.2.2 (0) + Call Alias (Not set) + ``` + + We are after the module ID: `MCUDTMOOZCVAM5EBNN4U3X2OGHNIY3BKPEW66HY4RTCYYVWXOE7ESVDQ` + +7. Swap the remote actor with our newly created one in the manifest file and don't forget to change the actor ID: + + ```yaml + actors: + - "./target/wasm32-unknown-unknown/release/echo_s.wasm" + # ... + actor: ${ECHO_ACTOR:MCUDTMOOZCVAM5EBNN4U3X2OGHNIY3BKPEW66HY4RTCYYVWXOE7ESVDQ} + # ... + ``` + +8. Now it's time to run our actor: + + ```bash + $ wasmcloud -m manifest.yaml + ``` + +9. As a final step we will send another request to `http://localhost:8080`: + + ```bash + curl http://localhost:8080/ + ``` + +## Using `wash` for better developer experience + +Previously we were using a declarative deployment model that did not allow us to modify resources at runtime. In this section, we will use `NATS` to allow `wasmcloud` to utilize self-managing [lattice network](https://wasmcloud.dev/reference/lattice/), and we can use `wash` to interact with the `wasmcloud` host via the lattice control interface (`ctl`). + +We will also use a local docker registry to store our echo actor to illustrate interacting with a local development version of an OCI registry. + +1. Since we are going to use `docker-compose` to run NATS server and image registry, you need to have `wasmcloud`, `wash`, `docker` and `docker-compose` installed on your machine. + +2. You can either use `docker-compose.yml` file in the project's directory or create one with the following content: + + ```yaml + version: "3" + services: + registry: + image: registry:2 + ports: + - "5000:5000" + nats: + image: nats:2.1.9 + ports: + - "6222:6222" + - "4222:4222" + - "8222:8222" + ``` + + We will run our containers in detached mode to reduce clutter. + + ```bash + $ docker-compose up -d + ``` + + Start a REPL session using `wash up` command: + + ```bash + $ wash up + ``` + + Check if session is running: + + ```bash + $ ctl get hosts + ``` + + It will output something like: + + ```bash + Host ID Uptime (seconds) + NDGPVEOZKAYT6JRL2C4BDVSW3PBBOYTWRLC2QFCSLXWDX4KCIRHM6WCZ 1357 + ``` + +3. Please open a new terminal, as the REPL is running in the current one. We will build our actor first, then will sign it: + + ```bash + $ cargo build --release + $ wash claims sign ./target/wasm32-unknown-unknown/release/echo.wasm -c wasmcloud:httpserver --name "echo" --ver 0.2.2 + ``` + + Or you can use `make` file in project's directory for convenience: + + ```bash + make release VERSION=0.2.2 + ``` + + Now we have our actor, `echo.wasm` and its signed version `echo_s.wasm` in `./target/wasm32-unknown-unknown/release` directory. + +3. Now it's time to push signed our actor into to local registry using `wash`: + + ```bash + wash reg push localhost:5000/echo:0.2.2 ./target/wasm32-unknown-unknown/release/echo_s.wasm --insecure + ``` + +4. Now, please go back to REPL terminal and run the actor from the local image registry: + + ```bash + ctl start actor localhost:5000/echo:0.2.2 + ``` + + The steps from now on are independent of our current example, but we've kept it for completeness: + +5. Start your capability provider that runs an HTML server: + + ```bash + ctl start provider wasmcloud.azurecr.io/httpserver:0.11.1 + ``` + + Check out https://wasmcloud.dev/app-dev/create-provider for how to write your own: + +6. Link the actor with capability using `wash`: + + ```bash + // Get actor and capability provider IDs using: + // ctl get inventory «HOST_ID» + + $ ctl get inventory NDGPVEOZKAYT6JRL2C4BDVSW3PBBOYTWRLC2QFCSLXWDX4KCIRHM6WCZ + + // Establish a contract between them using link command + // Pass along environment variables required by the capability provider using: + // ctl link «ACTOR_ID» «PROVIDER_ID» «CONTRACT_ID» PORT=8080 + + $ ctl link MCUDTMOOZCVAM5EBNN4U3X2OGHNIY3BKPEW66HY4RTCYYVWXOE7ESVDQ VAG3QITQQ2ODAOWB5TTQSDJ53XK3SHBEIFNK4A YJ5RKAX2UNSCAPHA5M wasmcloud:httpserver PORT=8080 + ``` + +7. You can use `ctl call` command in the REPL window to test out our actor: + + ```bash + ctl call «ACTOR_ID» HandleRequest {"method": "GET", "path": "/", "body": "", "queryString":"","header":{}} + ``` + This will output response JSON along with some raw bytes which our REPL terminal does not know how to interpret: + + ```bash + Call response (raw): ��statusCode�Ȧstatus�OK�header��body�D{"method":"GET","path":"/","query_string":"","headers":{},"body":[]} + ``` + + Or you can query `http://localhost:8080` via `curl` from a seperate terminal window: + + ```bash + curl http://localhost:8080/ + ``` + + Or just visit `http://localhost:8080/` address via browser: \ No newline at end of file diff --git a/echo/docker-compose.yml b/echo/docker-compose.yml new file mode 100644 index 00000000..d47a4276 --- /dev/null +++ b/echo/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3" +services: + registry: + image: registry:2 + ports: + - "5000:5000" + nats: + image: nats:2.1.9 + ports: + - "6222:6222" + - "4222:4222" + - "8222:8222" diff --git a/echo/manifest.yaml b/echo/manifest.yaml new file mode 100644 index 00000000..9ac61517 --- /dev/null +++ b/echo/manifest.yaml @@ -0,0 +1,14 @@ +labels: + sample: "wasmcloud echo" +actors: + - "wasmcloud.azurecr.io/echo:0.2.0" +capabilities: + - image_ref: wasmcloud.azurecr.io/httpserver:0.11.1 + link_name: default +links: + - actor: ${ECHO_ACTOR:MBCFOPM6JW2APJLXJD3Z5O4CN7CPYJ2B4FTKLJUR5YR5MITIU7HD3WD5} + provider_id: "VAG3QITQQ2ODAOWB5TTQSDJ53XK3SHBEIFNK4AYJ5RKAX2UNSCAPHA5M" + contract_id: "wasmcloud:httpserver" + link_name: default + values: + PORT: 8080 \ No newline at end of file diff --git a/echo/src/lib.rs b/echo/src/lib.rs index ce7a7e6f..6a2595b9 100644 --- a/echo/src/lib.rs +++ b/echo/src/lib.rs @@ -1,17 +1,20 @@ use serde::Serialize; use std::collections::HashMap; -extern crate wapc_guest as guest; -use guest::prelude::*; -use wasmcloud_actor_core as actorcore; +use wasmcloud_actor_core as actor; use wasmcloud_actor_http_server as http; -#[no_mangle] -pub fn wapc_init() { - actorcore::Handlers::register_health_request(health); - http::Handlers::register_handle_request(hello_world); +use wapc_guest::prelude::*; + +#[derive(Serialize)] +struct EchoResponse { + method: String, + path: String, + query_string: String, + headers: HashMap, + body: Vec, } -pub fn hello_world(r: http::Request) -> HandlerResult { +pub fn handle_request(r: http::Request) -> HandlerResult { let echo = EchoResponse { method: r.method, path: r.path, @@ -23,15 +26,12 @@ pub fn hello_world(r: http::Request) -> HandlerResult { Ok(http::Response::json(echo, 200, "OK")) } -fn health(_h: actorcore::HealthCheckRequest) -> HandlerResult { - Ok(actorcore::HealthCheckResponse::healthy()) +fn health(_h: actor::HealthCheckRequest) -> HandlerResult { + Ok(actor::HealthCheckResponse::healthy()) } -#[derive(Serialize)] -struct EchoResponse { - method: String, - path: String, - query_string: String, - headers: HashMap, - body: Vec, +#[no_mangle] +pub fn wapc_init() { + actor::Handlers::register_health_request(health); + http::Handlers::register_handle_request(handle_request); } diff --git a/extras/Cargo.lock b/extras/Cargo.lock index befebabf..887af9b0 100644 --- a/extras/Cargo.lock +++ b/extras/Cargo.lock @@ -20,7 +20,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "extras" -version = "0.2.0" +version = "0.2.1" dependencies = [ "serde_json", "wapc-guest", diff --git a/extras/Cargo.toml b/extras/Cargo.toml index 302aa160..e9298c87 100644 --- a/extras/Cargo.toml +++ b/extras/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "extras" -version = "0.2.0" +version = "0.2.1" authors = ["wasmcloud Team"] edition = "2018" @@ -16,4 +16,4 @@ serde_json = "1.0" [profile.release] # Optimize for small code size -opt-level = "s" +opt-level = "s" \ No newline at end of file diff --git a/extras/README.md b/extras/README.md index a2af924b..aa4d0c90 100644 --- a/extras/README.md +++ b/extras/README.md @@ -1,16 +1,102 @@ -# New Actor Template -Use cargo generate to create a new actor module from this template. +## How to use built-in `wasmcloud:extras` capability provider -[Learn how to write](https://wascc.dev/tutorials/first-actor/) waSCC actors, or [explore the actor concept](https://wascc.dev/docs/concepts/actors/). +The `wasmcloud` host runtime comes with a built-in capability provider (wasmcloud:extras) that includes some useful and fairly common tools. In this tutorial we will generate a random number and retrieve some information like request ID and number of requests using `wasmcloud:extras`. -To generate new keys, use `make keys`. This will use `nk` to generate both sets of keys for you, and then write them to the `.keys` directory. +1. Please install `wasmcloud` and `wash` binaries if you do not have them installed already: -To build your new module, use `make build`. This will compile your code with `cargo`, and then sign it with `wascap` using the keys in `.keys`. + [https://wasmcloud.dev/overview/installation/](https://wasmcloud.dev/overview/installation/) -## Tool Requirements + ```bash + $ wasmcloud --version + $ wash --version + ``` -- Cargo and Rust are required -- Make is recommended, but not strictly necessary -- [wascap](https://github.com/wascc/wascap) is required -- [nk](https://github.com/encabulators/nkeys) is required if you need to generate keys (which you almost certainly do) +2. Compile and sign the actor: + ```bash + $ cargo build --release + + $ wash claims sign ./target/wasm32-unknown-unknown/release/extras.wasm -c wasmcloud:httpserver -c c wasmcloud:extras --name "extras" --ver 0.2.1 + ``` + + Please note we are signing our actor for multiple capabilities including the built-in ones: `wasmcloud:httpserver` and `wasmcloud:extras`. Failing to sign our actor with those capabilities will prevent our actor from using them, as wasmcloud uses a deny-by-default security model for capabilities. + +3. Get the actor ID: + + ```bash + $ wash claims inspect ./target/wasm32-unknown-unknown/release/extras_s.wasm + ``` + + This will output cryptographically signed ID for our actor like: + + ```bash + Module MDAR7HG42IAZBHJQNS2CQPYJPCSN55CDCKBYSUDVY2R4ZB6YDFONID2B + ``` + +4. Now it is time to get the provider ID for `wasmcloud:extras`: + + ``` + // Start a REPL session + $ wash up + + // Get the host ID + $ ctl get hosts + + // Retrieve the inventory details using the host ID + $ wash ctl get inventory «HOST_ID» + ``` + + This will output something like: + + ```bash + Provider ID Link Name Image Reference + VAHNM37G4ARHZ3CYHB3L34M6TYQWQR6IZ4QVYC4NYZWTJCJ2LWP7S6Z2 __wasmcloud_lattice_cache N/A + VDHPKGFKDI34Y4RN4PWWZHRYZ6373HYRSNNEM4UTDLLOGO5B37TSVREP default N/A + ``` + + We need the ID for the `default` one. We are using remote capability provider for `wasmcloud:httpserver` and its ID is provided below. + + We are in the process of adding the provider name into the inventory output. + +5. You can create `manifest` file with the IDs you get above or use the one, `manifest.yaml`, in the project's directory as an example. You can use that file as a base but you'll have to replace the actor IDs in the links section with the actor ID that you found above in step 3: + + ```bash + # manifest.yaml + labels: + sample: "wasmcloud extra" + actors: + - "./target/wasm32-unknown-unknown/release/extras_s.wasm" + capabilities: + - image_ref: wasmcloud.azurecr.io/httpserver:0.11.1 + link_name: default + links: + - actor: «ACTOR_ID» + # Remote provider ID, no need to change unless you use different image + provider_id: "VAG3QITQQ2ODAOWB5TTQSDJ53XK3SHBEIFNK4AYJ5RKAX2UNSCAPHA5M" + contract_id: "wasmcloud:httpserver" + link_name: default + values: + PORT: 8080 + - actor: «ACTOR_ID» + provider_id: "VDHPKGFKDI34Y4RN4PWWZHRYZ6373HYRSNNEM4UTDLLOGO5B37TSVREP" + contract_id: "wasmcloud:extras" + link_name: default + ``` + +6. Now it's time to run the actor: + + ```bash + $ wasmcloud -m manifest.yaml + ``` + +7. Visit `http://localhost:8080` to see the result: + + ```bash + curl http://localhost:8080/ + ``` + + You will get a response like: + + ```json + `{"guid":"76d9f7c4-13e9-4b15-b200-e295ac5dee31","random":99,"sequence":7}` + ``` diff --git a/extras/manifest.yaml b/extras/manifest.yaml new file mode 100644 index 00000000..7dfd9a75 --- /dev/null +++ b/extras/manifest.yaml @@ -0,0 +1,18 @@ +labels: + sample: "wasmcloud Extras" +actors: + - "./target/wasm32-unknown-unknown/release/extras_s.wasm" +capabilities: + - image_ref: wasmcloud.azurecr.io/httpserver:0.11.1 + link_name: default +links: + - actor: "MDAR7HG42IAZBHJQNS2CQPYJPCSN55CDCKBYSUDVY2R4ZB6YDFONID2B" + provider_id: "VAG3QITQQ2ODAOWB5TTQSDJ53XK3SHBEIFNK4AYJ5RKAX2UNSCAPHA5M" + contract_id: "wasmcloud:httpserver" + link_name: default + values: + PORT: 8080 + - actor: "MDAR7HG42IAZBHJQNS2CQPYJPCSN55CDCKBYSUDVY2R4ZB6YDFONID2B" + provider_id: "VDHPKGFKDI34Y4RN4PWWZHRYZ6373HYRSNNEM4UTDLLOGO5B37TSVREP" + contract_id: "wasmcloud:extras" + link_name: default diff --git a/extras/src/lib.rs b/extras/src/lib.rs index 3eb075ba..ebd924b3 100644 --- a/extras/src/lib.rs +++ b/extras/src/lib.rs @@ -1,11 +1,10 @@ -#[macro_use] -extern crate serde_json; -extern crate wapc_guest as guest; -use guest::prelude::*; +use serde_json::json; use wasmcloud_actor_core as actor; use wasmcloud_actor_extras as extras; use wasmcloud_actor_http_server as http; +use wapc_guest::prelude::*; + #[actor::init] fn init() { http::Handlers::register_handle_request(display_extras); @@ -19,5 +18,6 @@ fn display_extras(_payload: http::Request) -> HandlerResult { "guid" : extras.request_guid()?, "sequence": extras.request_sequence()?, }); + Ok(http::Response::json(result, 200, "OK")) }