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:
parent
43fdd8ad62
commit
6f94000c80
@ -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:
|
Directory "mysql/apis" contains below listed API's files:
|
||||||
|
|
||||||
- `addbank.txt`
|
- `bank.txt`
|
||||||
- `addbranch.txt`
|
- `branch.txt`
|
||||||
- `addteller.txt`
|
- `teller.txt`
|
||||||
- `addcustomer.txt`
|
- `customer.txt`
|
||||||
- `getbank.txt`
|
|
||||||
- `getbranch.txt`
|
|
||||||
- `getteller.txt`
|
|
||||||
- `getcustomer.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.
|
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.
|
||||||
|
@ -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"
|
|
||||||
}
|
|
41
databases/mysql/apis/bank.txt
Normal file
41
databases/mysql/apis/bank.txt
Normal 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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,12 +1,12 @@
|
|||||||
1.
|
1.
|
||||||
Linux
|
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.
|
2.
|
||||||
Windows
|
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.
|
3.
|
||||||
@ -16,3 +16,27 @@ JSON response
|
|||||||
"status_code": 0,
|
"status_code": 0,
|
||||||
"status_description": "Successful"
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -16,3 +16,27 @@ JSON response
|
|||||||
"status_code": 0,
|
"status_code": 0,
|
||||||
"status_description": "Successful"
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,12 +1,12 @@
|
|||||||
1.
|
1.
|
||||||
Linux
|
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.
|
2.
|
||||||
Windows
|
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.
|
3.
|
||||||
@ -16,3 +16,27 @@ JSON response
|
|||||||
"status_code": 0,
|
"status_code": 0,
|
||||||
"status_description": "Successful"
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -206,8 +206,6 @@ pub fn get_branch_data(pool: &mysql::Pool) -> BranchResponseData {
|
|||||||
my_status_description = "Successful".to_owned();
|
my_status_description = "Successful".to_owned();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Assign values to struct variable
|
|
||||||
|
|
||||||
BranchResponseData {
|
BranchResponseData {
|
||||||
status_code: my_status_code,
|
status_code: my_status_code,
|
||||||
status_description: my_status_description,
|
status_description: my_status_description,
|
||||||
|
@ -94,7 +94,7 @@ async fn index() -> impl Responder {
|
|||||||
String::new()
|
String::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/addbank")]
|
#[post("/bank")]
|
||||||
async fn add_bank(bank_data: web::Json<BankData>, data: web::Data<mysql::Pool>) -> impl Responder {
|
async fn add_bank(bank_data: web::Json<BankData>, data: web::Data<mysql::Pool>) -> impl Responder {
|
||||||
let bank_name = &bank_data.bank_name;
|
let bank_name = &bank_data.bank_name;
|
||||||
let _country = &bank_data.country;
|
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)
|
web::Json(response_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/addbranch")]
|
#[post("/branch")]
|
||||||
async fn add_branch(
|
async fn add_branch(
|
||||||
branch_data: web::Json<BranchData>,
|
branch_data: web::Json<BranchData>,
|
||||||
data: web::Data<mysql::Pool>,
|
data: web::Data<mysql::Pool>,
|
||||||
@ -118,7 +118,7 @@ async fn add_branch(
|
|||||||
web::Json(response_data)
|
web::Json(response_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/addteller")]
|
#[post("/teller")]
|
||||||
async fn add_teller(
|
async fn add_teller(
|
||||||
teller_data: web::Json<TellerData>,
|
teller_data: web::Json<TellerData>,
|
||||||
data: web::Data<mysql::Pool>,
|
data: web::Data<mysql::Pool>,
|
||||||
@ -132,7 +132,7 @@ async fn add_teller(
|
|||||||
web::Json(response_data)
|
web::Json(response_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/addcustomer")]
|
#[post("/customer")]
|
||||||
async fn add_customer(
|
async fn add_customer(
|
||||||
customer_data: web::Json<CustomerData>,
|
customer_data: web::Json<CustomerData>,
|
||||||
data: web::Data<mysql::Pool>,
|
data: web::Data<mysql::Pool>,
|
||||||
@ -146,28 +146,28 @@ async fn add_customer(
|
|||||||
web::Json(response_data)
|
web::Json(response_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/getbank")]
|
#[get("/bank")]
|
||||||
async fn get_bank(data: web::Data<mysql::Pool>) -> impl Responder {
|
async fn get_bank(data: web::Data<mysql::Pool>) -> impl Responder {
|
||||||
let bank_response_data = db_layer::get_bank_data(&data);
|
let bank_response_data = db_layer::get_bank_data(&data);
|
||||||
|
|
||||||
web::Json(bank_response_data)
|
web::Json(bank_response_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/getbranch")]
|
#[get("/branch")]
|
||||||
async fn get_branch(data: web::Data<mysql::Pool>) -> impl Responder {
|
async fn get_branch(data: web::Data<mysql::Pool>) -> impl Responder {
|
||||||
let branch_response_data = db_layer::get_branch_data(&data);
|
let branch_response_data = db_layer::get_branch_data(&data);
|
||||||
|
|
||||||
web::Json(branch_response_data)
|
web::Json(branch_response_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/getteller")]
|
#[get("/teller")]
|
||||||
async fn get_teller(data: web::Data<mysql::Pool>) -> impl Responder {
|
async fn get_teller(data: web::Data<mysql::Pool>) -> impl Responder {
|
||||||
let teller_response_data = db_layer::get_teller_data(&data);
|
let teller_response_data = db_layer::get_teller_data(&data);
|
||||||
|
|
||||||
web::Json(teller_response_data)
|
web::Json(teller_response_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/getcustomer")]
|
#[get("/customer")]
|
||||||
async fn get_customer(data: web::Data<mysql::Pool>) -> impl Responder {
|
async fn get_customer(data: web::Data<mysql::Pool>) -> impl Responder {
|
||||||
let customer_response_data = db_layer::get_customer_data(&data);
|
let customer_response_data = db_layer::get_customer_data(&data);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user