You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, Serverpod's RPC system does not support middleware functionality, which makes it challenging to implement cross-cutting concerns, logging, or custom request preprocessing for all or selected RPC endpoints.
Proposal
Introduce middleware capabilities to the RPC handling process in Serverpod. This would allow developers to add custom functions that can intercept, process, or modify requests and responses as they pass through the RPC pipeline. Middleware should support chaining and provide mechanisms for both synchronous and asynchronous operations.
Use Case
For example, a developer could add an authentication middleware to automatically check user credentials on every RPC request, or add logging middleware to track request/response payloads. This would centralize common logic and reduce code duplication across RPC handlers.
Alternatives
Currently, to add such functionality, developers must manually insert logic into each endpoint or handler, which reduces maintainability and increases risk of inconsistency. Some developers might use hooks or custom wrappers, but these approaches are less flexible compared to a dedicated middleware system.
Additional context
Adding middleware support to the RPC in Serverpod would make it more extensible and allow for better separation of concerns. This feature is common in many web frameworks, and its inclusion would improve developer experience.
Activity
gitrema commentedon Nov 12, 2025
The proposal LGTM
jwelmac commentedon Nov 12, 2025
This looks like an awesome addition.