request-scoped

Manage per-request dependency injection in Axum Rust applications.

Updated May 10, 2026
One-click install
npx skills add https://github.com/jymchng/injectable --skill request-scoped
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: request-scoped
Source: https://github.com/jymchng/injectable/tree/main/skills/request-scoped
Command: npx skills add https://github.com/jymchng/injectable --skill request-scoped

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires axum, injectable, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill unit solves the problem of managing dependencies that require a unique instance per HTTP request in Rust applications, such as database transactions or request-specific state.

Core Features & Use Cases

  • Per-Request Scoping: Ensures that dependencies like database connections are created once per HTTP request, maintaining isolation and avoiding conflicts.
  • Axum Compatibility: Integrates seamlessly with Axum, a Rust web framework, for typed dependency injection.
  • Compile-Time Safety: Catches circular dependencies and missing registrations at compile time, preventing runtime errors.

Quick Start

Use the injectable skill to define a request-scoped dependency in your Axum application.

Frequently Asked Questions about request-scoped

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does per-request dependency injection work in Rust Axum applications?

Per-request dependency injection in Axum uses the `Inject<T>` extractor to instantiate services uniquely for each HTTP request. This maintains isolation for dependencies like database transactions, ensuring no state conflicts occur across concurrent web requests.

When do I need request-scoped dependencies for my Rust web server?

You need request-scoped dependencies when your HTTP requests require isolated state, such as unique database transactions or request-specific data. Request-scoped scoping ensures each HTTP request receives its own dedicated instance, preventing data conflicts.

How do I set up request-scoped database transactions using Axum and the injectable crate?

You set up request-scoped services by defining dependencies with the `injectable` crate and retrieving them in Axum handlers via the `Inject<T>` extractor. This ensures a fresh instance is created and injected per HTTP request.

Does the injectable crate catch dependency injection errors at compile time in Rust?

Yes, the injectable crate provides compile-time safety for dependency injection. It catches circular dependencies and missing service registrations during the Rust build process, preventing runtime errors commonly associated with dynamic injection frameworks.

Can I use this request-scoped dependency injection without the Axum framework?

No, this request-scoped dependency injection mechanism specifically requires the Axum web framework. It integrates tightly with Axum's `Inject<T>` extractor system to manage the lifecycle of request-scoped instances.