https://github.com/timvw/knative-rust-axum
https://github.com/timvw/knative-rust-axum
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/timvw/knative-rust-axum
- Owner: timvw
- Created: 2024-05-21T19:56:38.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-21T20:08:55.000Z (about 1 year ago)
- Last Synced: 2025-01-01T12:22:21.663Z (5 months ago)
- Language: Rust
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rust HTTP Function
Welcome to your new Rust function project! The boilerplate
[axum](https://github.com/tokio-rs/axum) web server is in
[`src/main.rs`](./src/main.rs). It's configured to invoke the `index`
function in [`src/handler.rs`](./src/handler.rs) in response to both
GET and POST requests. You should put your desired behavior inside
that `index` function.The app will expose three endpoints:
* `/` Triggers the `index` function, for either GET or POST methods
* `/health/readiness` The endpoint for a readiness health check
* `/health/liveness` The endpoint for a liveness health checkYou may use any of the available [axum features](https://docs.rs/axum/latest/axum/) to fulfill the requests at those
endpoints.## Development
This is a fully self-contained application, so you can develop it as
you would any other Rust application, e.g.```shell script
cargo build
cargo test
cargo run
```Once running, the function is available at and
the health checks are at and
. To POST data to the function,
a utility such as `curl` may be used:```console
curl -d '{"hello": "world"}' \
-H'content-type: application/json' \
http://localhost:8080
```## Deployment
Use `func` to containerize your application, publish it to a registry
and deploy it as a Knative Service in your Kubernetes cluster:```shell script
func deploy --registry=docker.io/
```You can omit the `--registry` option by setting the `FUNC_REGISTRY`
environment variable. And if you forget, you'll be prompted.The output from a successful deploy should show the URL for the
service, which you can also get via `func info`, e.g.```console
curl $(func info -o url)
```Have fun!