Background:
You're tasked with implementing a rate limiting middleware for a RESTful API built using Spring Boot. The rate limiter should restrict the number of requests from a client within a specified time window.
- Implement a Spring Boot middleware component that applies rate limiting based on the client's IP address.
- The middleware should allow a maximum of N requests per minute (N is configurable).
- If a client exceeds the request limit within a minute, subsequent requests from that client should receive a "429 Too Many Requests" HTTP response.
- The rate limiting configuration should be adjustable without requiring application restart.
- You can use any appropriate data structure or mechanism for tracking request counts and timestamps.
- Consider thread safety and performance implications.
- Ensure proper error handling and logging.
- Write unit tests to validate the functionality.