tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.73k stars 2.59k forks source link

[feat] Request for Pre-processing and Post-processing Interceptors Similar to Actix-web Middleware #11571

Closed fashionbrot closed 3 weeks ago

fashionbrot commented 3 weeks ago

Describe the problem

Sure! Here’s a draft for your GitHub issue to request the addition of pre-processing and post-processing interceptors in Tauri:

Title: Request for Pre-processing and Post-processing Interceptors Similar to Actix-web Middleware

Body:

I would like to propose a feature enhancement for Tauri to introduce pre-processing and post-processing interceptors, similar to the middleware functionality available in Actix-web. This would greatly enhance the flexibility and functionality of Tauri applications by allowing developers to implement common middleware patterns, such as:

1、Logging: Automatically log incoming requests and responses for better observability. 2、Authorization: Implement authorization checks before processing requests to ensure that users have the necessary permissions. 3、Authentication: Facilitate identity verification by allowing interceptors to validate tokens or other authentication methods. By enabling these interceptors, Tauri can provide a more robust framework for building applications that require standardized request handling, error management, and security measures.

This feature would greatly improve the developer experience and increase the capabilities of Tauri as a modern application framework.

Thank you for considering this request!

Describe the solution you'd like

I envision a system similar to the middleware architecture in Actix-web. Here’s a rough outline of how it could be implemented:

Interceptor Trait: Introduce a trait called that defines methods for pre-processing and post-processing. This would allow developers to create custom interceptors for their specific needs.Interceptor

Alternatives considered

I envision a system similar to the middleware architecture in Actix-web. Here’s a rough outline of how it could be implemented:

Interceptor Trait: Introduce a trait called that defines methods for pre-processing and post-processing. This would allow developers to create custom interceptors for their specific needs.Interceptor

Additional context

No response

FabianLars commented 3 weeks ago

Are we talking about requests to tauri's "server" and/or to custom protocols in general, or rather any kind of web requests to potentially unknown urls?

For the first one I don't see much value in this tbh,maybe for the tauri:// protocol but not for custom protocols as a whole.

In the case of the latter modifying requests is impossible on platforms other than Windows (with the currently used system webviews)

FabianLars commented 3 weeks ago

Closing as i assume it's the latter which is blocked by system limitations and already tracked here https://github.com/tauri-apps/tauri/issues/4899