This repository implements a ticket booking system using gRPC and REST APIs. Below are the commands to generate protocol buffer files and examples of cURL commands for testing the REST endpoints.
Run the following command to generate the necessary Go files for gRPC and protocol buffer support:
protoc --go_out=. --go-grpc_out=. ticket.protoStart the server and client by running server/server.go and client/client.go files and than use below REST API Endpoints
Endpoint: POST /purchase-ticket
Description: Allows a user to purchase a ticket.
Sample Request:
curl -X POST "http://localhost:8080/purchase-ticket" \
-H "Content-Type: application/json" \
-d '{
"from": "Mumbai",
"to": "Delhi",
"user": {
"first_name": "Ravi",
"last_name": "Kumar",
"email": "ravi.kumar@example.com"
},
"price_paid": 500
}'Endpoint: GET /get-ticket-receipt
Description: Fetch the ticket receipt for a user.
Sample Request:
curl -X GET "http://localhost:8080/get-ticket-receipt?email=ravi.kumar@example.com"Endpoint: GET /view-users-in-section
Description: View all users in a specific section (A or B).
Sample Requests:
- Section A:
curl -X GET "http://localhost:8080/view-users-in-section?section=A" - Section B:
curl -X GET "http://localhost:8080/view-users-in-section?section=B"
Endpoint: POST /remove-user
Description: Remove a user from the booking system.
Sample Request:
curl -X POST http://localhost:8080/remove-user \
-H "Content-Type: application/json" \
-d '{
"email": "ravi.kumar@example.com"
}'Endpoint: POST /modify-seat
Description: Modify the seat assigned to a user.
Sample Request:
curl -X POST http://localhost:8080/modify-seat \
-H "Content-Type: application/json" \
-d '{
"email": "ravi.kumar@example.com",
"new_seat": "A_1"
}'- Ensure the server is running on
localhost:8080before making requests. - Replace email and other parameters in the requests as necessary.