-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Description
Implement middleware support in MetaSSR to allow developers to intercept and modify requests and responses during the server-side rendering (SSR) process. This feature would enable custom logic to be applied at various points in the request lifecycle, such as authentication, logging, caching, or request transformation.
Polyglot Programming Support
MetaSSR will leverage the Metacall polyglot runtime, allowing middleware to be written in various programming languages like Python, JavaScript, or Ruby. This means developers can define middleware in their preferred language and easily integrate it into their applications.
Example in Javascript:
// ./src/middlewares/logger.js
export function handler(req) {
console.log(`[LOG_FROM_JS]: Request received at: ${new Date()}`);
}
Example in Python:
# ./src/middlewares/logger.py
def handler(req):
print(f"[LOG_FROM_PY]: Request received at: {datetime.now()}")
- Benefits:
- Provides flexibility in handling requests, allowing for centralized control over functionalities like security, session management, and performance optimization.
- Simplifies the addition of cross-cutting concerns, such as authentication or logging, without duplicating code across different routes or components.
- Polyglot support allows developers to write middleware in multiple languages, making it adaptable for diverse use cases.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request