-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat/Persist-Resource * feat: Added generic Trait for Persist * feat: Ability to easily save structs to File * feat: Ability to easily save structs to File * feat: Added example and improved error handling * feat: Improved Error handling & Formatting * feat: Improved Error handling and Docs * feat: formatting * feat: cargo sort * feat: Added comment recommendations * feat: fixed loader project_name issue * feat: added missing ";" * feat: cargo fmt * feat: error & example improvements * feat: move optional feature down * refactor: make path filesystem agnostic * refactor: remove stale comment * bug: accidental file create on load * refactor: sort dependencies Co-authored-by: chesedo <pieter@chesedo.me>
- Loading branch information
Showing
11 changed files
with
453 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,12 @@ | ||
[package] | ||
name = "persist" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
|
||
[dependencies] | ||
rocket = { version = "0.5.0-rc.1", features = ["json"] } | ||
serde = { version = "1.0", features = ["derive"] } | ||
sqlx = { version = "0.5", features = ["runtime-tokio-native-tls", "postgres"] } | ||
shuttle-service = { version = "0.5.0", features = ["web-rocket", "persist"] } |
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,35 @@ | ||
# Persist Example | ||
|
||
An example app to show what you can do with shuttle. | ||
|
||
## How to deploy the example | ||
|
||
To deploy the examples, check out the repository locally | ||
|
||
```bash | ||
$ git clone https://github.com/shuttle-hq/shuttle.git | ||
``` | ||
|
||
navigate to the Persist root folder | ||
|
||
```bash | ||
$ cd examples/rocket/persist | ||
``` | ||
|
||
Pick a project name that is something unique - in shuttle, | ||
projects are globally unique. Then run | ||
|
||
```bash | ||
$ cargo shuttle deploy --name=$PROJECT_NAME | ||
``` | ||
|
||
Once deployed you can post to the endpoint the following values: | ||
```bash | ||
curl -X POST -H "Content-Type: application/json" -d '{"date":"2020-12-22", "temp_high":5, "temp_low":5, "precipitation": 5}' {$PROJECT_NAME}.shuttleapp.rs | ||
``` | ||
|
||
The json data will then persist within Shuttle it can be queried with the following curl request | ||
|
||
```bash | ||
curl {$PROJECT_NAME}.shuttleapp.rs/2020-12-22 | ||
``` |
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 @@ | ||
name = "persist-rocket-app" |
Oops, something went wrong.