1
0
mirror of https://github.com/actix/examples synced 2024-11-23 22:41:07 +01:00

remove methods from paths

This commit is contained in:
Rob Ede 2023-07-17 18:56:41 +01:00
parent 43fdd8ad62
commit 6f94000c80
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
12 changed files with 129 additions and 131 deletions

View File

@ -71,13 +71,9 @@ You may need to ensure that you are running the commands with the correct MySQL
Directory "mysql/apis" contains below listed API's files:
- `addbank.txt`
- `addbranch.txt`
- `addteller.txt`
- `addcustomer.txt`
- `getbank.txt`
- `getbranch.txt`
- `getteller.txt`
- `getcustomer.txt`
- `bank.txt`
- `branch.txt`
- `teller.txt`
- `customer.txt`
Copy the curl request on each of the ".txt" and execute them on separate terminals. Each ".txt" contains curl request and expected JSON response data.

View File

@ -1,17 +0,0 @@
1.
Linux
curl -d '{"bank_name":"Bank ABC","country":"Kenya"}' -H 'Content-Type: application/json' http://127.0.0.1:8080/addbank
2.
Windows
curl -H "Content-type:application/json" --data-binary "{\"bank_name\":\"Bank ABC\",\"country\":\"Kenya\"}" http://127.0.0.1:8080/addbank
3.
JSON response
{
"status_code": 0,
"status_description": "Successful"
}

View File

@ -0,0 +1,41 @@
1.
Linux
curl -d '{"bank_name":"Bank ABC","country":"Kenya"}' -H 'Content-Type: application/json' http://127.0.0.1:8080/bank
2.
Windows
curl -H "Content-type:application/json" --data-binary "{\"bank_name\":\"Bank ABC\",\"country\":\"Kenya\"}" http://127.0.0.1:8080/bank
3.
JSON response
{
"status_code": 0,
"status_description": "Successful"
}
4.
Linux
curl 'http://localhost:8080/bank'
5.
Windows
curl http://localhost:8080/bank
6.
JSON response
{
"status_code": 0,
"status_description": "Successful",
"bank_data": [
{
"bank_name": "bank abc",
"country": "kenya"
}
]
}

View File

@ -1,12 +1,12 @@
1.
Linux
curl -d '{"branch_name":"HQ branch", "location":"Central Business District"}' -H 'Content-Type: application/json' http://127.0.0.1:8080/addbranch
curl -d '{"branch_name":"HQ branch", "location":"Central Business District"}' -H 'Content-Type: application/json' http://127.0.0.1:8080/branch
2.
Windows
curl -H "Content-type:application/json" --data-binary "{\"branch_name\":\"HQ branch\", \"location\":\"Central Business District\"}" http://127.0.0.1:8080/addbranch
curl -H "Content-type:application/json" --data-binary "{\"branch_name\":\"HQ branch\", \"location\":\"Central Business District\"}" http://127.0.0.1:8080/branch
3.
@ -16,3 +16,27 @@ JSON response
"status_code": 0,
"status_description": "Successful"
}
4.
Linux
curl 'http://localhost:8080/branch'
5.
Windows
curl http://localhost:8080/branch
6.
JSON response
{
"status_code": 0,
"status_description": "Successful",
"branch_data": [
{
"branch_name": "hq branch",
"location": "central business district"
}
]
}

View File

@ -16,3 +16,27 @@ JSON response
"status_code": 0,
"status_description": "Successful"
}
4.
Linux
curl 'http://localhost:8080/customer'
5.
Windows
curl http://localhost:8080/customer
6.
JSON response
{
"status_code": 0,
"status_description": "Successful",
"customer_data": [
{
"customer_name": "peter paul",
"branch_name": "central business district"
}
]
}

View File

@ -1,23 +0,0 @@
1.
Linux
curl 'http://localhost:8080/getbank'
2.
Windows
curl http://localhost:8080/getbank
3.
JSON response
{
"status_code": 0,
"status_description": "Successful",
"bank_data": [
{
"bank_name": "bank abc",
"country": "kenya"
}
]
}

View File

@ -1,23 +0,0 @@
1.
Linux
curl 'http://localhost:8080/getbranch'
2.
Windows
curl http://localhost:8080/getbranch
3.
JSON response
{
"status_code": 0,
"status_description": "Successful",
"branch_data": [
{
"branch_name": "hq branch",
"location": "central business district"
}
]
}

View File

@ -1,23 +0,0 @@
1.
Linux
curl 'http://localhost:8080/getcustomer'
2.
Windows
curl http://localhost:8080/getcustomer
3.
JSON response
{
"status_code": 0,
"status_description": "Successful",
"customer_data": [
{
"customer_name": "peter paul",
"branch_name": "central business district"
}
]
}

View File

@ -1,23 +0,0 @@
1.
Linux
curl 'http://localhost:8080/getteller'
2.
Windows
curl http://localhost:8080/getteller
3.
JSON response
{
"status_code": 0,
"status_description": "Successful",
"teller_data": [
{
"teller_name": "john doe",
"branch_name": "central business district"
}
]
}

View File

@ -1,12 +1,12 @@
1.
Linux
curl -d '{"teller_name":"John Doe", "branch_name":"Central Business District"}' -H 'Content-Type: application/json' http://127.0.0.1:8080/addteller
curl -d '{"teller_name":"John Doe", "branch_name":"Central Business District"}' -H 'Content-Type: application/json' http://127.0.0.1:8080/teller
2.
Windows
curl -H "Content-type:application/json" --data-binary "{\"teller_name\":\"John Doe\", \"branch_name\":\"Central Business District\"}" http://127.0.0.1:8080/addteller
curl -H "Content-type:application/json" --data-binary "{\"teller_name\":\"John Doe\", \"branch_name\":\"Central Business District\"}" http://127.0.0.1:8080/teller
3.
@ -16,3 +16,27 @@ JSON response
"status_code": 0,
"status_description": "Successful"
}
4.
Linux
curl 'http://localhost:8080/teller'
5.
Windows
curl http://localhost:8080/teller
6.
JSON response
{
"status_code": 0,
"status_description": "Successful",
"teller_data": [
{
"teller_name": "john doe",
"branch_name": "central business district"
}
]
}

View File

@ -206,8 +206,6 @@ pub fn get_branch_data(pool: &mysql::Pool) -> BranchResponseData {
my_status_description = "Successful".to_owned();
}
//Assign values to struct variable
BranchResponseData {
status_code: my_status_code,
status_description: my_status_description,

View File

@ -94,7 +94,7 @@ async fn index() -> impl Responder {
String::new()
}
#[post("/addbank")]
#[post("/bank")]
async fn add_bank(bank_data: web::Json<BankData>, data: web::Data<mysql::Pool>) -> impl Responder {
let bank_name = &bank_data.bank_name;
let _country = &bank_data.country;
@ -104,7 +104,7 @@ async fn add_bank(bank_data: web::Json<BankData>, data: web::Data<mysql::Pool>)
web::Json(response_data)
}
#[post("/addbranch")]
#[post("/branch")]
async fn add_branch(
branch_data: web::Json<BranchData>,
data: web::Data<mysql::Pool>,
@ -118,7 +118,7 @@ async fn add_branch(
web::Json(response_data)
}
#[post("/addteller")]
#[post("/teller")]
async fn add_teller(
teller_data: web::Json<TellerData>,
data: web::Data<mysql::Pool>,
@ -132,7 +132,7 @@ async fn add_teller(
web::Json(response_data)
}
#[post("/addcustomer")]
#[post("/customer")]
async fn add_customer(
customer_data: web::Json<CustomerData>,
data: web::Data<mysql::Pool>,
@ -146,28 +146,28 @@ async fn add_customer(
web::Json(response_data)
}
#[get("/getbank")]
#[get("/bank")]
async fn get_bank(data: web::Data<mysql::Pool>) -> impl Responder {
let bank_response_data = db_layer::get_bank_data(&data);
web::Json(bank_response_data)
}
#[get("/getbranch")]
#[get("/branch")]
async fn get_branch(data: web::Data<mysql::Pool>) -> impl Responder {
let branch_response_data = db_layer::get_branch_data(&data);
web::Json(branch_response_data)
}
#[get("/getteller")]
#[get("/teller")]
async fn get_teller(data: web::Data<mysql::Pool>) -> impl Responder {
let teller_response_data = db_layer::get_teller_data(&data);
web::Json(teller_response_data)
}
#[get("/getcustomer")]
#[get("/customer")]
async fn get_customer(data: web::Data<mysql::Pool>) -> impl Responder {
let customer_response_data = db_layer::get_customer_data(&data);