A streamlined Spring Boot application with Split.io feature flag integration.
The application has a simplified architecture:
controller: Contains the REST controller that handles HTTP requestsservice: Contains the service interface and feature flag implementation- Main application class that bootstraps the Spring Boot application and configures the Split.io client
- Java 17 or higher
- Maven 3.6 or higher
- Split.io API key
- feature flag called 'feature_a' in your environment
The application uses an environment variable for the Split.io API key:
SPLIT_API_KEY=your-actual-split-api-key
You can set this in your environment or use the provided run script.
Using the run script:
chmod +x run_command
./run_commandManually with Maven:
export SPLIT_API_KEY=your-actual-split-api-key
mvn spring-boot:runThe application will start on port 8080.
Once the application is running, you can test the API by visiting:
http://localhost:8080/api/message
This endpoint returns the treatment value from the Split.io feature flag "feature_a" (typically "on" or "off").
The application uses Split.io for feature flagging:
- The Split.io Java client is initialized in the main application class
- Feature flags are configured via the Split.io dashboard
- The API endpoint returns the raw treatment value from the "feature_a" flag
- User key is currently hardcoded as "user-key-123" for demonstration
To customize the feature flag behavior:
- Modify
FeatureFlagMessageServiceto use different flag names or additional conditions - Add more sophisticated user targeting by replacing the hardcoded user key
- Add conditional logic based on treatment values to control application behavior