Skip to content

basic-tutorials/lets_get_rusty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Let's Get Rusty

A learning repository for Rust programming language featuring practical examples and projects.

Project Structure

lets_get_rusty/
├── README.md
└── basic-rust-api/
    ├── Cargo.toml
    └── src/
        └── main.rs

Projects

1. Basic Rust API

A simple REST API built with Rust and Actix-web demonstrating basic CRUD operations for managing books.

Features

  • RESTful endpoints for managing books
  • In-memory storage using Mutex for thread-safe data access
  • JSON request/response handling
  • Basic error handling
  • Concurrent request processing

Running the API

  1. Navigate to the API directory:
cd basic-rust-api
  1. Build the project:
cargo build
  1. Run the server:
cargo run

The server will start on http://127.0.0.1:8080

API Endpoints

Method Endpoint Description
GET /books Get all books
GET /books/{id} Get a book by ID
POST /books Create a new book
DELETE /books/{id} Delete a book by ID

Usage Examples

Create a Book:

curl -X POST -H "Content-Type: application/json" -d '{"id": 1, "title": "Rust Programming", "author": "John Doe"}' http://localhost:8080/books

Get All Books:

curl http://localhost:8080/books

Get a Specific Book:

curl http://localhost:8080/books/1

Delete a Book:

curl -X DELETE http://localhost:8080/books/1

Prerequisites

  • Rust (latest stable version)
  • Cargo (comes with Rust)

Installation

Clone the repository:

git clone https://github.com/Ismat-Samadov/lets_get_rusty.git
cd lets_get_rusty

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

About

RUST api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages