axum-jetpack

Crates.ioaxum-jetpack
lib.rsaxum-jetpack
version0.8.1
created_at2026-01-05 21:25:02.206177+00
updated_at2026-01-09 16:48:46.868745+00
descriptionContains a collection of tools to improve the axum framework and security aspects
homepage
repositoryhttps://github.com/heart4it/axum-jetpack
max_upload_size
id2024606
size98,751
(heart4it)

documentation

README

Axum Jetpack

This project should be considered experimental for now. It contains a collection of tools to improve the axum framework and security aspects.

Currently it contains the following features:

  • Size limit middleware: A configurable middleware for Axum framework that enforces request size limits with intelligent buffering and streaming strategies.

    Features

    • Content-Type Based Limits - Set different limits for different content types
    • Wildcard Support - Use patterns like image/* or video/*
    • Buffering Strategy - Intelligent decision to buffer or stream
    • Human-Readable Sizes - Use strings like "10MB" or "100KB"
    • Early soft rejection - First weak rejection based on Content-Length header
    • Early hard rejection - Counts bytes and disallows request if limit is exceeded.
    • Streaming Support - Handle large files without buffering
    • Customizable Defaults - Configure default behavior
    • Multipart Support - Handle file upload limits
    • Production Ready - Proper error handling and responses

    Important notes:

    • This middleware is only effective when also other axum limits set correctly. Like: Timeouts, Max concurrent connections, CORS etc.
    • Notice that also default axum limits are enforced which can conflict with this middleware. Make sure to set them correctly.

Installation

[dependencies]
axum-jetpack = "0.8.1" # currently supported axum version

Usage example

Open src/example/example.rs

Run tests:

cargo test -- --nocapture

Commit count: 8

cargo fmt