,'\
_.----. ____ ,' _\ ___ ___ ____
_,-' `. | | /`. \,-' | \ / | | \ |`.
\ __ \ '-. | / `. ___ | \/ | '-. \ | |
\. \ \ | __ | |/ ,','_ `. | | __ | \| |
\ \/ /,' _`.| ,' / / / / | ,' _`.| | |
\ ,-'/ / \ ,' | \/ / ,`.| / / \ | |
\ \ | \_/ | `-. \ `' /| | || \_/ | |\ |
\ \ \ / `-.`.___,-' | |\ /| \ / | | |
\ \ `.__,'| |`-._ `| |__| \/ | `.__,'| | | |
\_.-' |__| `-._ | '-.| '-.| | |
`' '-._|
Gotta catch 'em all!
Package showing how you can build an API using smithy-rs
This package requires an initial build using Gradle to generate the Cargo workspace:
❯❯❯ ./gradlew assembleAfter the first build any change to the model will be detected by Cargo and the code-generator should run automatically.
❯❯❯ cargo build
❯❯❯ cargo run
❯❯❯ cargo testIf the SDKs are not getting update after a model change, you can manually trigger it:
❯❯❯ ./gradlew clean && ./gradlew assembleThere are end-to-end unit tests that can be run with
❯❯❯ cargo testTo run and test the service manually:
❯❯❯ RUST_LOG=aws_smithy_http_server=debug,pokemon_service=debug cargo run❯❯❯ curl -k -H "Accept: application/json" https://localhost:13734/pokemon-species/pikachu |jqGradle and Smithy can be intimidating and Smithy-rs is not jet released on Maven. For this reason, this repository provides a script that can be used to provision a new project: the script generates all the necessary Gradle scaffolding and provides code-generation using a GIT sub-module.
❯❯❯ ./docs/template/new.sh service-crate-name destination-directoryFor example this command
❯❯❯ ./docs/template/new.sh pokemon-service /tmp/pokemon-servicewill generate a new Gradle project inside /tmp/pokemon-service, a Cargo
workspace with 3 crates, pokemon-service, the business logic, pokemon-service-server-sdk,
the server Smithy-rs SDK for the server (code-generated) and pokemon-service-client-sdk, the
client Smithy-rs SDK (code-generated).
The repo will only generate the SDKs for client and server for the very simple model that can be found here. This is done by providing a smithy-build.json.
Once this command has succeeded, you can use these commands in the new repo:
❯❯❯ ./gradlew clean && ./gradlew assemble # regenerate after a model change.
❯❯❯ cargo build # build the workspace.
❯❯❯ cargo run # run the service.
❯❯❯ cargo test # test the workspace.There are some slides built with Marp in the docs/slides folder
that can be viewed by opening the rendered HTML.
Slides can be rebuilt by running:
❯❯❯ cd docs && marp slides.md❯❯❯ openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
-keyout certs/localhost.key -out certs/localhost.crt -subj "/CN=localhost" \
-addext "basicConstraints=critical,CA:false" \
-addext "subjectAltName=DNS:localhost"