-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): Migrates remaining go examples from monorepo
This moves the two examples that weren't moved from the monorepo. This also adds tests and adds simple smoke tests for each component. I also modified the examples job to run once per week to ensure things don't go stale with new versions of `wash` Signed-off-by: Taylor Thomas <[email protected]>
- Loading branch information
1 parent
e8b3f29
commit 8e1f3a4
Showing
434 changed files
with
31,690 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ go.work.sum | |
|
||
# env file | ||
.env | ||
.envrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# TinyGo HTTP Password Checker | ||
|
||
This repository contains a WebAssembly Component written in [TinyGo][tinygo], which: | ||
|
||
- Implements a [`wasi:http`][wasi-http]-compliant HTTP handler | ||
- Uses the [`httpserver` provider][httpserver-provider] to serve requests | ||
- Can be declaratively provisioned with [`wadm`][wadm] | ||
|
||
[wasi-http]: https://github.com/WebAssembly/wasi-http | ||
[httpserver-provider]: https://github.com/wasmCloud/wasmCloud/tree/main/crates/provider-http-server | ||
[wadm]: https://github.com/wasmCloud/wadm | ||
[tinygo]: https://tinygo.org/getting-started/install/ | ||
[wash]: https://wasmcloud.com/docs/ecosystem/wash/ | ||
|
||
# Dependencies | ||
|
||
Before starting, ensure that you have the following installed: | ||
|
||
- The [TinyGo toolchain][tinygo] | ||
- [`wash`, the WAsmcloud SHell][wash] installed. | ||
|
||
# Quickstart | ||
|
||
To get started developing this repository quickly, clone the repo and run `wash dev`: | ||
|
||
```console | ||
wash dev | ||
``` | ||
|
||
`wash dev` does many things for you: | ||
|
||
- Starts the [wasmCloud host][wasmcloud-host] that can run your WebAssembly component | ||
- Builds this project | ||
- Builds a declarative WADM manifest consisting of: | ||
- Your locally built component | ||
- A [HTTP server provider][httpserver-provider] which will receive requests from the outside world (on port 8000 by default) | ||
- Necessary links between providers and your component so your component can handle web traffic | ||
- Deploys the built manifest (i.e all dependencies to run this application) locally | ||
- Watches your code for changes and re-deploys when necessary. | ||
|
||
[wasmcloud-host]: https://wasmcloud.com/docs/concepts/hosts | ||
|
||
## Send a request to the running component | ||
|
||
Once `wash dev` is serving your component, to send a request to the running component (via the HTTP server provider): | ||
|
||
```console | ||
curl localhost:8000/api/v1/check -d '{"value": "tes12345!"}' | ||
``` | ||
|
||
You should see a JSON response like: | ||
|
||
```json | ||
{ | ||
"valid": false, "message": "insecure password, try including more special characters, using uppercase letters or using a longer password" | ||
} | ||
``` | ||
|
||
## Adding Capabilities | ||
|
||
To learn how to extend this example with additional capabilities, see the [Adding Capabilities](https://wasmcloud.com/docs/tour/adding-capabilities?lang=rust) section of the wasmCloud documentation. | ||
|
||
# Issues/ FAQ | ||
|
||
<summary> | ||
<description> | ||
|
||
## `curl` produces a "failed to invoke" error | ||
|
||
</description> | ||
|
||
If `curl`ing produces | ||
|
||
``` | ||
➜ curl localhost:8000 | ||
failed to invoke `wrpc:http/incoming-handler.handle`: failed to invoke `wrpc:http/[email protected]`: failed to shutdown synchronous parameter channel: not connected% | ||
``` | ||
|
||
You *may* need to just wait a little bit -- the HTTP server takes a second or two to start up. | ||
|
||
If the issue *persists*, you *may* have a lingering HTTP server provider running on your system. You can use `pgrep` to find it: | ||
|
||
```console | ||
❯ pgrep -la ghcr_io | ||
4007604 /tmp/wasmcloudcache/NBCBQOZPJXTJEZDV2VNY32KGEMTLFVP2XJRZJ5FWEJJOXESJXXR2RO46/ghcr_io_wasmcloud_http_server_0_23_1 | ||
``` | ||
|
||
</summary> |
Oops, something went wrong.