Extend¶
When configuration alone isn’t enough, you can extend HARP by creating custom applications. A HARP application is a standard Python package with lifecycle hooks and dependency injection support.
What are HARP applications?¶
HARP applications are Python packages that integrate with HARP’s lifecycle and dependency injection system. They can:
Add custom controllers and routes
Implement custom storage backends
Provide reusable services
Hook into request/response processing
Extend the dashboard UI
Learning from built-in applications¶
The best way to learn is by examining HARP’s built-in applications in harp_apps/:
proxy (
harp_apps.proxy): HTTP proxy with connection pooling and health checkshttp_client (
harp_apps.http_client): HTTP client with caching and retry logicstorage (
harp_apps.storage): Database backends (SQLite, PostgreSQL, MySQL, Redis)dashboard (
harp_apps.dashboard): Web UI with React frontendrules (
harp_apps.rules): Transaction lifecycle scripting engine
Each application has an __app__.py file defining its lifecycle hooks. For example, see harp_apps.acme/__app__.py for a minimal application template.
Creating your own application¶
Generate a project with application support:
uvx --python 3.13 harp-proxy create project
Answer “yes” when asked about creating an application folder.
Define your application in
your_app/__app__.py:from harp.config import Application application = Application( on_bind=..., # Register services in DI container on_bound=..., # Configure services after DI resolution on_ready=..., # Initialize when server starts on_shutdown=..., # Cleanup on shutdown )
Enable your application:
uv run harp-proxy server --enable your_app
Detailed documentation¶
For comprehensive guides on application development, see:
Application protocol - Basic structure and settings
Application structure - File organization and conventions
Dependency injection - Service registration and resolution
Events - Lifecycle hooks and event handling
Testing - Testing applications and fixtures