Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: middleware with polyglot support #27

Open
hulxv opened this issue Sep 22, 2024 · 0 comments
Open

feat: middleware with polyglot support #27

hulxv opened this issue Sep 22, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@hulxv
Copy link
Collaborator

hulxv commented Sep 22, 2024

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.
@hulxv hulxv added the enhancement New feature or request label Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant