This is a simple Actix web application that demonstrates the usage of Actix web framework for building a web server in Rust.
- Manages a list of managers and employees.
- Utilizes Actix web for handling HTTP requests.
- Implements a basic in-memory database.
Before running the application, ensure you have the following installed:
- Rust: Installation Guide
- Cargo: Rust's package manager, included with the Rust installation.
-
Clone the repository:
git clone [email protected]:saiprasad-coditas/MySqlRust.git
-
Change into the project directory:
cd employeePortal
-
Build and run the application:
cargo run
The server will start on
http://127.0.0.1:8080/
.
- The API is accessible at
http://127.0.0.1:8080/api
. - The application initializes an in-memory database and creates tables on startup.
/api/managers
: Retrieve a list of managers./api/employees
: Retrieve a list of employees.
- Actix web: A powerful, pragmatic, and extremely fast web framework for Rust.
- SQLite: A C library that provides a lightweight disk-based database.
-
Configure MySQL Connection:
Modify the connection parameters in
Database::new()
method ofdatabase.rs
with your MySQL server details. -
Build and run the application:
cargo run
The server will start on
http://127.0.0.1:8080/
.
- The application initializes a MySQL database and creates tables on startup.
- If the specified database (
employeeprotal
) does not exist, it will be created.
The application uses two tables:
-
Manager Table:
id
(INT): Primary key with auto-increment.name
(VARCHAR): Manager's name.role
(VARCHAR): Manager's role.
-
Employee Table:
id
(INT): Primary key with auto-increment.name
(VARCHAR): Employee's name.role
(VARCHAR): Employee's role.manager_id
(INT): Foreign key referencing theid
column of the Manager table.
/api/managers
: Retrieve a list of managers./api/employees
: Retrieve a list of employees.
This Rust Actix web application provides RESTful API endpoints to manage managers and employees. It uses in-memory storage for simplicity.
- CRUD operations for managers and employees.
- Utilizes Actix web for handling HTTP requests.
- Demonstrates basic usage of asynchronous Rust.
- Add Manager:
POST /manager
- Get Managers:
GET /manager
- Update Manager:
PUT /manager/{id}
- Delete Manager:
DELETE /manager/{id}
- Add Employee:
POST /employee
- Get Employees:
GET /employee
- Update Employee:
PUT /employee/{id}
- Delete Employee:
DELETE /employee/{id}
{
"id": 1,
"name": "John Doe",
"role": "Manager"
}
{
"id": 1,
"name": "Jane Doe",
"role": "Developer",
"manager_id": 1
}