Files
mach_examples/06-middleware-scoping.svg
2026-05-23 18:36:17 -05:00

53 lines
3.1 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 360" width="760" height="360">
<rect width="760" height="360" fill="#09080f"/>
<defs>
<style>text{font-family:'JetBrains Mono','Fira Code',monospace}</style>
</defs>
<!-- Outermost: Global .before / .after -->
<rect x="30" y="20" width="700" height="310" rx="14" fill="#1a1328" stroke="#7c3aed" stroke-width="1.5"/>
<text x="50" y="46" fill="#c084fc" font-size="11" font-weight="700">Global .before</text>
<text x="50" y="62" fill="#9580b8" font-size="9">session()</text>
<text x="610" y="46" fill="#c084fc" font-size="11" font-weight="700">Global .after</text>
<text x="610" y="62" fill="#9580b8" font-size="9">call(log_request)</text>
<!-- Middle: Resource .before / .after -->
<rect x="60" y="78" width="640" height="230" rx="12" fill="#111827" stroke="#3b82f6" stroke-width="1.5"/>
<text x="80" y="102" fill="#60a5fa" font-size="11" font-weight="700">Resource .before</text>
<text x="80" y="118" fill="#7b9ec9" font-size="9">logged_in()</text>
<text x="570" y="102" fill="#60a5fa" font-size="11" font-weight="700">Resource .after</text>
<!-- Inner: Route pipeline -->
<rect x="90" y="134" width="580" height="152" rx="10" fill="#0f0d1a" stroke="#06b6d4" stroke-width="1.5"/>
<text x="110" y="158" fill="#22d3ee" font-size="11" font-weight="700">Route Pipeline — POST /todos</text>
<!-- Steps inside route -->
<rect x="110" y="172" width="100" height="36" rx="6" fill="#1e293b" stroke="#3b82f6" stroke-width="0.75"/>
<text x="160" y="194" text-anchor="middle" fill="#93c5fd" font-size="10" font-weight="600">param()</text>
<line x1="210" y1="190" x2="228" y2="190" stroke="#64748b" stroke-width="1.5"/>
<polygon points="238,190 228,185 228,195" fill="#64748b"/>
<rect x="238" y="172" width="100" height="36" rx="6" fill="#1e293b" stroke="#8b5cf6" stroke-width="0.75"/>
<text x="288" y="194" text-anchor="middle" fill="#c4b5fd" font-size="10" font-weight="600">db()</text>
<line x1="338" y1="190" x2="356" y2="190" stroke="#64748b" stroke-width="1.5"/>
<polygon points="366,190 356,185 356,195" fill="#64748b"/>
<rect x="366" y="172" width="100" height="36" rx="6" fill="#1e293b" stroke="#f59e0b" stroke-width="0.75"/>
<text x="416" y="194" text-anchor="middle" fill="#fcd34d" font-size="10" font-weight="600">emit()</text>
<line x1="466" y1="190" x2="484" y2="190" stroke="#64748b" stroke-width="1.5"/>
<polygon points="494,190 484,185 484,195" fill="#64748b"/>
<rect x="494" y="172" width="100" height="36" rx="6" fill="#1e293b" stroke="#10b981" stroke-width="0.75"/>
<text x="544" y="194" text-anchor="middle" fill="#6ee7b7" font-size="10" font-weight="600">redirect()</text>
<!-- Route .before / .after labels -->
<text x="110" y="244" fill="#22d3ee" font-size="9">Route .before runs first inside this scope</text>
<text x="110" y="260" fill="#22d3ee" font-size="9">Route .after runs last inside this scope</text>
<!-- Execution order arrows at bottom -->
<text x="380" y="348" text-anchor="middle" fill="#64748b" font-size="10">Execution order: global .before → resource .before → route pipeline → resource .after → global .after</text>
</svg>