Thank you for your interest in contributing to Glean's HTTP Proxy! This document provides guidelines and instructions for development.
- Development Setup
- Making Changes
- Code Style
- Testing
- Documentation
- File Structure
- Adding a New Filter
- Need Help?
- Clone the repository:
git clone https://github.com/gleanwork/glean-proxy.git
cd glean-proxy-
Ensure
java,bazel, andpipare installed. We use Java 17.0.5 and Bazel 7.4.1. -
Install precommit hooks:
pip install pre-commit
pre-commit install- Build the project:
bazel build //src/main/java/com/glean/proxy:proxy- Run tests:
bazel test //src/test/java/com/glean/proxy/...- Fork the repository
- Install precommit hooks:
pre-commit install - Create your feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -am 'Add new feature' - Push to the branch:
git push origin feature/my-feature - Submit a pull request
- Use Java for all new code
- Follow the existing code style (enforced by pre-commit hooks)
- Write tests for new functionality
- Add unit tests for new features
- Ensure all tests pass before submitting a pull request
- Use the provided test utilities and fixtures
- Update documentation for any changed functionality
- Keep the README.md up to date
The Java codebase is organized as follows:
src/
├── main/java/com/glean/proxy/
│ ├── filters/ # Filters that can be applied to proxied requests
│ │ └── helpers/ # Helper classes for filters
│ ├── schemas/ # API response schema classes
│ ├── ProxyMain.java
│ ├── FilterConfiguration.java
│ └── ...
└── test/java/com/glean/proxy/ # Mirrors `main` package
├── filters/
│ └── helpers/
├── test_utils/
└── ...
To add a new HTTP filter to GleanProxy, do the following:
Create your filter class in src/main/java/com/glean/proxy/filters/, extending HttpFiltersAdapter from LittleProxy:
import org.littleshoot.proxy.HttpFiltersAdapter;
public class MyCustomFilter extends HttpFiltersAdapter {
@Override
public HttpResponse clientToProxyRequest(HttpObject httpObject) {
// Your filter logic here
return null; // Return null to let the request through
}
}Add your filter to the filterRegistry in FilterConfiguration.java:
MyCustomFilter.class.getSimpleName(),
() -> {
String someConfig = System.getenv("MY_CUSTOM_CONFIG");
return (request, ctx) -> new MyCustomFilter(request, someConfig);
}To enable your filter, add it to the desired <platform>_FILTERS environment variable, for example: GOOGLE_FILTERS=MyCustomFilter.
Add your filter's config variables to README.md (if applicable):
**MyCustomFilter**
| Variable | Description | Default |
|----------|-------------|---------|
| `MY_CUSTOM_CONFIG` | Custom configuration variable | None |- Issues: GitHub Issues
- Email: support@glean.com