A simple web server built with Go that interacts with Kafka and Redis. It demonstrates how to handle POST requests to send data to Kafka and GET requests to retrieve data from Redis.
- POST /post: Sends data to a Kafka topic.
- GET /get: Retrieves the latest data from Redis.
- Go: The main programming language used.
- Kafka: Used for message queuing.
- Redis: Used for data storage.
- Docker: Used to containerize Kafka, Zookeeper, and Redis.
- Docker and Docker Compose
- Go (Golang)
-
Clone the repository:
git clone https://github.com/yourusername/go-kafka-redis-webserver.git cd go-kafka-redis-webserver -
Set up Docker containers:
docker-compose up -d
-
Install Go dependencies:
go get github.com/IBM/sarama go get github.com/go-redis/redis/v8 go get github.com/gorilla/mux
-
Run the Go web server:
go run main.go
- Description: Sends data to a Kafka topic.
- Request body:
{ "key": "value" } - Example:
curl -X POST -d '{"key":"value"}' -H "Content-Type: application/json" http://localhost:8080/post
- Description: Retrieves the latest data from Redis.
- Example:
curl http://localhost:8080/get