-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f1e3dd
commit 44ec063
Showing
3 changed files
with
109 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Rust HTTP Function | ||
|
||
Welcome to your new Rust function project! The boilerplate | ||
[actix](https://actix.rs/) app can be found in | ||
[`src/main.rs`](./src/main.rs). The `handle` function will respond to | ||
POST requests containing a `CloudEvent`. | ||
|
||
The app will expose three endpoints: | ||
|
||
* `/` Triggers the `handle` function for a POST method | ||
* `/health/readiness` The endpoint for a readiness health check | ||
* `/health/liveness` The endpoint for a liveness health check | ||
|
||
You may use any of the available [actix | ||
features](https://actix.rs/docs/) 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 <http://localhost:8080> and | ||
the health checks are at <http://localhost:8080/health/readiness> and | ||
<http://localhost:8080/health/liveness>. To POST an event to the | ||
function, a utility such as `curl` may be used: | ||
|
||
```console | ||
curl -X POST -d '{"name": "bootsy"}' \ | ||
-H'Content-type: application/json' \ | ||
-H'ce-specversion: 1.0' \ | ||
-H'ce-id: 1' \ | ||
-H'ce-source: http://cloudevents.io' \ | ||
-H'ce-type: dev.knative.example' \ | ||
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/<YOUR_ACCOUNT> | ||
``` | ||
|
||
You can omit the `--registry` option by setting the `FUNC_REGISTRY` | ||
environment variable. And if you forget, you'll be prompted. | ||
|
||
Have fun! |
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,52 @@ | ||
# Rust HTTP Function | ||
|
||
Welcome to your new Rust function project! The boilerplate | ||
[actix](https://actix.rs/) app can be found in | ||
[`src/main.rs`](./src/main.rs). The `index` function will respond to | ||
both GET and POST requests as configured in the `main` 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 check | ||
|
||
You may use any of the available [actix | ||
features](https://actix.rs/docs/) 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 <http://localhost:8080> and | ||
the health checks are at <http://localhost:8080/health/readiness> and | ||
<http://localhost:8080/health/liveness>. To POST data to the function, | ||
a utility such as `curl` may be used: | ||
|
||
```console | ||
curl -X POST -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/<YOUR_ACCOUNT> | ||
``` | ||
|
||
You can omit the `--registry` option by setting the `FUNC_REGISTRY` | ||
environment variable. And if you forget, you'll be prompted. | ||
|
||
Have fun! |