axum_js_advice-1.0.1 has been yanked.
Axum JS Advice Middleware
This project allows you to includes a custom middleware that injects a JavaScript alert in your axum application, advising users to disable JavaScript for enhanced security.
Features
- Custom Middleware: Adds an HTML
<script>tag to responses, displaying a warning pop-up if JavaScript is enabled. - Request and Response Buffering: Reads and modifies HTTP request/response bodies to include the custom script.
- Minimal Setup: Built with simplicity in mind using
axumandtokio.
How It Works
The middleware intercepts responses and appends a JavaScript alert to the body. The alert advises users to disable JavaScript for their safety.
Example Warning Script Injected:
Usage
Then, add axum_js_advice() in your middleware layer, for example:
use ;
use js_advice;
async
Example Output
When visiting http://127.0.0.1:3000/, the response will include:
Hello from `POST /`
If you have JavaScript enabled, a reminder will pop up asking you to disable it; otherwise, you can browse freely.
License
This project is licensed under the GPL License. See the LICENSE file for details.