Skip to content

Here's a simple Rust API that leverages the Rocket framework and the Diesel ORM. The goal was to make the process simple and intuitive for Go, Ruby and Python developers looking to build APIs in Rust to understand

License

Notifications You must be signed in to change notification settings

goodylili/rusting-rocket-diesel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rusting Rocket on Diesel

Rusting Rocket on Diesel is a simple REST API built with Rust, Rocket, and Diesel that provides CRUD operations on a table of students.

Getting Started

To get started with this project, you will need to have Rust and Cargo installed. Once you have those installed, you can clone the repository and run the following commands to install the dependencies and start the server:

git clone https://github.com/Goodnessuc/rusting-rocket-diesel.git
cd rusting-rocket-diesel
cargo install diesel_cli
diesel setup
diesel migration run
cargo run

Running these commands will start the server on port 8000. Once the server is up and running, you can proceed to test the API.

API Documentation

The following is a list of the API endpoints available in this project:

  • GET /students - Get a list of all students
  • GET /students/:id - Get a specific student by ID
  • POST /students - Create a new student
  • PUT /students/:id - Update an existing student
  • DELETE /students/:id - Delete a student

Example Requests

The following are some example requests that you can use to test the API:

  • GET /students - Get a list of all students
curl http://localhost:8000/students
  • GET /students/1 - Get a specific student by ID
curl http://localhost:8000/students/1
  • POST /students - Create a new student
curl -X POST http://localhost:8000/student -H 'Content-Type: application/json' -d '{"first_name": "John", "last_name": "Doe", "age": 17}'
  • PUT /students/1 - Update an existing student
curl -X PUT http://localhost:8000/students/1 -H 'Content-Type: application/json' -d '{"first_name": "Jane", "last_name": "Doe", "age": 18}'
  • DELETE /students/1 - Delete a student
curl -X DELETE http://localhost:8000/students/1

Contributing

If you would like to contribute to this project, please feel free to fork the repository and submit a pull request.

License

This project is licensed under the MIT License.

About

Here's a simple Rust API that leverages the Rocket framework and the Diesel ORM. The goal was to make the process simple and intuitive for Go, Ruby and Python developers looking to build APIs in Rust to understand

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published