Skip to main content
Glama
nesirat

MCP Vulnerability Management System

by nesirat
http2.py1.43 kB
from fastapi import Request from starlette.middleware.base import BaseHTTPMiddleware from starlette.types import ASGIApp from typing import List, Optional from app.core.config import settings class HTTP2Middleware(BaseHTTPMiddleware): def __init__(self, app: ASGIApp): super().__init__(app) self.push_paths = { "/": [ "/static/css/main.css", "/static/js/main.js", "/static/images/logo.png" ], "/api/v1/docs": [ "/static/css/swagger.css", "/static/js/swagger.js" ] } async def dispatch(self, request: Request, call_next): # Get response response = await call_next(request) # Add HTTP/2 headers response.headers["x-http2-enabled"] = "true" # Check if server push is supported if "h2" in request.headers.get("upgrade", "").lower(): # Get paths to push based on current path current_path = request.url.path paths_to_push = self.push_paths.get(current_path, []) # Add Link headers for server push if paths_to_push: link_headers = [] for path in paths_to_push: link_headers.append(f"<{path}>; rel=preload") response.headers["link"] = ", ".join(link_headers) return response

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nesirat/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server