mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
Refactor: move middleware definition (#6552)
This commit is contained in:
@@ -2,8 +2,6 @@ from abc import ABC, abstractmethod
|
||||
from enum import Enum
|
||||
from typing import ClassVar, Protocol
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
|
||||
class AppMode(Enum):
|
||||
OSS = 'oss'
|
||||
@@ -16,7 +14,7 @@ class SessionMiddlewareInterface(Protocol):
|
||||
pass
|
||||
|
||||
|
||||
class OpenhandsConfigInterface(ABC):
|
||||
class ServerConfigInterface(ABC):
|
||||
CONFIG_PATH: ClassVar[str | None]
|
||||
APP_MODE: ClassVar[AppMode]
|
||||
POSTHOG_CLIENT_KEY: ClassVar[str]
|
||||
@@ -28,21 +26,11 @@ class OpenhandsConfigInterface(ABC):
|
||||
"""Verify configuration settings."""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def verify_github_repo_list(self, installation_id: int | None) -> None:
|
||||
"""Verify that repo list is being called via user's profile or Github App installations."""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def get_config(self) -> dict[str, str]:
|
||||
"""Configure attributes for frontend"""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def attach_middleware(self, api: FastAPI) -> None:
|
||||
"""Attach required middleware for the current environment"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class MissingSettingsError(ValueError):
|
||||
"""Raised when settings are missing or not found."""
|
||||
|
||||
Reference in New Issue
Block a user