salvo-middleware

Implement cross-cutting middleware across Salvo routes and handlers with hoop() and FlowCtrl.

20|5|Updated Jan 11, 2026
One-click install
npx skills add https://github.com/salvo-rs/salvo-skills --skill salvo-middleware
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: salvo-middleware
Source: https://github.com/salvo-rs/salvo-skills/tree/main/skills/salvo-middleware
Command: npx skills add https://github.com/salvo-rs/salvo-skills --skill salvo-middleware

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Middleware pattern in Salvo enables applying cross-cutting concerns across routes and handlers. This skill provides a structured approach to implementing, attaching, and composing middleware to reduce duplication and improve consistency.

Core Features & Use Cases

  • Attach global or route-scoped middleware using hoop() to apply authentication, logging, and CORS across routes
  • Demonstrate the onion-model execution order and declarative control via FlowCtrl
  • Use cases include adding authentication, request logging, timing, and custom headers across API routers

Quick Start

Attach a logger and auth middleware to a router and observe the request/response flow.

Frequently Asked Questions about salvo-middleware

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

FAQPage Schema
How do I add authentication and logging middleware to Salvo routes?

Attach authentication and logging middleware to Salvo routes using the hoop() function. It applies cross-cutting concerns globally or at the route level to ensure consistent behavior across handlers.

How does FlowCtrl control request flow in Salvo middleware?

FlowCtrl provides declarative control over Salvo middleware execution, demonstrating the onion-model order. It manages request and response flow to compose nested router scenarios effectively.

Can I apply CORS middleware globally across all Salvo API routers?

Yes, you can apply CORS middleware globally across Salvo API routers using hoop(). This ensures consistent cross-origin resource sharing behavior without duplicating code across individual handlers.

What is the best way to compose nested router middleware in Salvo?

The best way to compose nested router middleware in Salvo is using hoop() attachments with FlowCtrl. This structured approach reduces duplication and enables declarative control across nested routing scenarios.

Why does my Salvo middleware execute in an unexpected order?

Salvo middleware executes following an onion-model pattern. Understanding this nested execution order and using FlowCtrl for declarative control ensures your middleware applies consistently across routes.

Do I need hoop() to attach custom headers across Salvo routes?

Yes, hoop() is required to attach custom headers and other cross-cutting concerns across Salvo routes. It enables applying timing, logging, and custom modifications consistently.