Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:24kchengYe MemoMind HttpExtension

From Leeroopedia
Knowledge Sources
Domains Software_Architecture, Extensibility
Last Updated 2026-10-28 00:00 GMT

Overview

HTTP extension interface for adding custom API endpoints under the /ext/ path prefix without modifying the core FastAPI application.

Description

The HttpExtension ABC allows extensions to provide a FastAPI `APIRouter` that gets mounted on the main application under `/ext/`. Extensions have full control over routes, request/response models, and handlers. The memory engine is passed to `get_router()` for database operations. Configure via `HINDSIGHT_API_HTTP_EXTENSION`.

Usage

Subclass this when building an extension that adds custom HTTP endpoints (e.g., billing dashboards, admin panels, integration webhooks).

Code Reference

Source Location

  • Repository: MemoMind
  • File: engine/hindsight_api/extensions/http.py
  • Lines: L1-101

Signature

class HttpExtension(Extension, ABC):
    @abstractmethod
    def get_router(self, memory: MemoryEngine) -> APIRouter: ...

Import

from hindsight_api.extensions.http import HttpExtension

I/O Contract

Inputs

Name Type Required Description
memory MemoryEngine Yes Engine instance for DB operations

Outputs

Name Type Description
get_router() returns APIRouter FastAPI router mounted under /ext/

Usage Examples

Adding Custom Endpoints

from fastapi import APIRouter
from hindsight_api.extensions import HttpExtension

class MyHttpExtension(HttpExtension):
    def get_router(self, memory):
        router = APIRouter()

        @router.get("/hello")
        async def hello():
            return {"message": "Hello from extension!"}

        @router.post("/custom/{bank_id}/action")
        async def custom_action(bank_id: str):
            pool = await memory._get_pool()
            # ... custom logic
            return {"status": "ok"}

        return router

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment