As the demand for real-time video communication grows, integrating video room management with third-party services becomes increasingly essential. The VideoKick project offers a Go-based solution that leverages the Twilio API for creating and managing video rooms, complemented by a logging system using Uber's Zap for efficient monitoring.
Directory Structure
The directory structure of the VideoKick project is designed for modularity and maintainability:
videokick/
├── docs/ # API documentation using Swagger
├── internal/
│ ├── video/ # Video module
│ │ └── handler.go # Handler for video endpoints
│ ├── twilio/ # Twilio client module
│ │ └── client.go # Twilio client initialization
│ └── pkg/ # Utility and common modules
│ └── logger.go # Logger configuration using Zap
├── main.go # Application entry point
└── routes/
└── routes.go # API routing configuration
Key Features
Video Room Creation: Utilizes the Twilio API to create unique video rooms for each request.
Efficient Logging: Employs Zap, a high-performance logger, for rapid and effective application logging.
API Documentation: Swagger is used for interactive documentation, facilitating developer exploration of the API.
Dependencies
- Gin: An HTTP framework used for routing and middleware handling.
-
Twilio: A service that supports video and voice communication, integrated via the
twilio-go
module. - Zap: A high-performance logger provided by Uber for fast and efficient application logging.
Installation Steps
- Clone the Repository
Begin by cloning the VideoKick repository to your local machine:
git clone https://gitlab.com/dioarafi1/videokick.git
cd videokick
- Install Dependencies
Ensure that Go is installed on your system. To download all required dependencies for the project, run:
go mod tidy
- Initialize Swagger
To set up API documentation, initialize Swagger with the command:
swag init
- Configure Environment
Set your Twilio SID and Token in a .env
file or a YAML configuration. Example format for .env
:
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_AUTH_TOKEN=xxxxxxxxxxxxxxxxxxxxxxx
TWILIO_VERIFY_SID=Vxxxxxxxxxxxxxxxxxxxxxxx
API Usage
Create Video Room
This endpoint is used to create a new video room with Twilio. The request is made using the POST method.
Sample Request:
curl -X POST http://localhost:8080/videos/room \
-H "Content-Type: application/json" \
-d '{
"uniqueName": "testRoom"
}'
Retrieve List of Video Rooms
To obtain a list of all existing video rooms, use the following endpoint with the GET method:
curl -X GET http://localhost:8080/videos/rooms
Twilio Configuration
The Twilio module is configured in internal/twilio/client.go
. For further customization, please refer to the Twilio Video API documentation and the Twilio Go Library.
Logger Configuration with Zap
The logger in this application is configured using Zap, with settings located in pkg/logger/logger.go
. The logger will be initialized in main.go
for global usage throughout the application.
Swagger Documentation
Once the server is running, the Swagger documentation can be accessed at the following endpoint:
Swagger Docs: http://localhost:8080/docs
Swagger provides an interactive interface to test each endpoint and view sample requests and responses from the API.
Additional References
- Gin Framework Documentation
- Twilio Video API Documentation
- Zap Logger Documentation
- Swagger for Go Documentation
By following this guide, you can easily set up and run VideoKick as a Twilio-based video room management service. This approach also offers flexibility in monitoring API activities through Zap logging and simplifies API exploration via Swagger.
Top comments (0)