https://github.com/madeindjs/rocket_mvc
An MVC web application built with Rocket.rs & Diesel.rs
https://github.com/madeindjs/rocket_mvc
diesel restful rocket rust
Last synced: 5 months ago
JSON representation
An MVC web application built with Rocket.rs & Diesel.rs
- Host: GitHub
- URL: https://github.com/madeindjs/rocket_mvc
- Owner: madeindjs
- License: mit
- Created: 2017-11-27T14:47:46.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-12T23:03:27.000Z (over 6 years ago)
- Last Synced: 2025-04-09T01:37:01.358Z (6 months ago)
- Topics: diesel, restful, rocket, rust
- Language: Rust
- Size: 50.8 KB
- Stars: 15
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rocket MVC
A REST web application build in [Rust](https://www.rust-lang.org/). It use [Rocket](https://rocket.rs) & [Diesel](http://diesel.rs/).
This sample just an API who allow you to edit recipes according to [REST](https://en.wikipedia.org/wiki/Representational_state_transfer) conventions.
- **List** recipes: GET /recipes
- **Create** recipes: POST /recipes
- **Show** recipe: GET /recipes/
- **Edit** recipe: GET /recipes//edit
- **Delete** recipe: DELETE /recipes/## Instalation
First you need to [install Rust](https://www.rust-lang.org/install.html). Then Clone the repository and go in the folder
~~~bash
$ git clone https://github.com/madeindjs/Rocket_MVC.git
$ cd Rocket_MVC
~~~According to [Rocket](https://rocket.rs), you need to use Nightly version of [Rust](https://www.rust-lang.org/)
~~~bash
$ rustup override set nightly
~~~Then install [diesel_cli](https://github.com/diesel-rs/diesel/tree/master/diesel_cli) and run database migrations
~~~bash
$ cargo install diesel_cli --no-default-features --features sqlite
$ diesel setup
~~~And now you can build project
~~~bash
$ cargo run
~~~## Example
This is an example with cURL.
1. First, create a recipe
~~~bash
$ curl -X POST 'http://localhost:8000/recipes' -d 'name=from_curl'
~~~2. Check if created
~~~bash
$ curl -X GET 'http://localhost:8000/recipes'
[{"id":1,"name":"from_curl"}]
~~~3. Update it
~~~bash
$ curl -X PUT 'http://localhost:8000/recipes/1' -d 'name=update_from_curl'
~~~~~~bash
$ curl -X GET 'http://localhost:8000/recipes/1'
{"id":1,"name":"update_from_curl"}
~~~4. Destroy record
~~~bash
$ curl -X DELETE 'http://localhost:8000/recipes/1'
~~~## Benchmark
TODO
## Benchmark
## License
[MIT](https://opensource.org/licenses/MIT)
[Rust]: https://www.rust-lang.org/