|
117 | 117 | <a href="#security-extractors"><span class="at">§</span>Security extractors</a> |
118 | 118 | <a href="#signatures"><span class="at">§</span>Signature primitives</a> |
119 | 119 | <a href="#di-demo"><span class="at">§</span>Dependency injection worked example</a> |
120 | | -</nav><button class="theme-btn" id="theme">◐ toggle theme</button><div class="side-foot"><a href="https://github.com/moonbitstack/moonapi/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/moonbitstack/moonapi/ci.yml?branch=master&label=CI&logo=github"></a><a href="https://mooncakes.io/docs/Lfan-ke/moonapi"><img alt="mooncakes" src="https://img.shields.io/badge/mooncakes-Lfan--ke%2Fmoonapi-1f6feb"></a></div></aside> |
121 | | -<main><header class="hero"><h1>moonapi</h1><p class="tag">A typed web framework for MoonBit — FastAPI-style routing and multi-version OpenAPI, on the moonasgi SEAM. Backend-agnostic — the async transport lives in the server (mooncat) that runs the app.</p><div class="badges"><a href="https://github.com/moonbitstack/moonapi/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/moonbitstack/moonapi/ci.yml?branch=master&label=CI&logo=github"></a><img alt="tests" src="https://img.shields.io/badge/tests-86%20passing%20%C3%974%20backends-0ca678"><a href="https://github.com/moonbitstack/moonapi"><img alt="GitHub" src="https://img.shields.io/badge/GitHub-source-24292f?logo=github"></a><img alt="license" src="https://img.shields.io/badge/license-Apache--2.0-6d5efc"></div><div class="install"><span class="prompt">$</span><code>moon add Lfan-ke/moonapi</code><button class="copy" data-copy="moon add Lfan-ke/moonapi">copy</button></div><div class="contract"><h2><span class="spark">✶</span> The contract at a glance</h2><pre><span class="k">let</span> app = <span class="ty">App</span>::new() |
| 120 | +</nav><button class="theme-btn" id="theme">◐ toggle theme</button><div class="side-foot"><a href="https://github.com/moonbitstack/moonapi/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/moonbitstack/moonapi/ci.yml?branch=master&label=CI&logo=github"></a><a href="https://mooncakes.io/docs/moonbitstack/moonapi"><img alt="mooncakes" src="https://img.shields.io/badge/mooncakes-Lfan--ke%2Fmoonapi-1f6feb"></a></div></aside> |
| 121 | +<main><header class="hero"><h1>moonapi</h1><p class="tag">A typed web framework for MoonBit — FastAPI-style routing and multi-version OpenAPI, on the moonasgi SEAM. Backend-agnostic — the async transport lives in the server (mooncat) that runs the app.</p><div class="badges"><a href="https://github.com/moonbitstack/moonapi/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/moonbitstack/moonapi/ci.yml?branch=master&label=CI&logo=github"></a><img alt="tests" src="https://img.shields.io/badge/tests-86%20passing%20%C3%974%20backends-0ca678"><a href="https://github.com/moonbitstack/moonapi"><img alt="GitHub" src="https://img.shields.io/badge/GitHub-source-24292f?logo=github"></a><img alt="license" src="https://img.shields.io/badge/license-Apache--2.0-6d5efc"></div><div class="install"><span class="prompt">$</span><code>moon add moonbitstack/moonapi</code><button class="copy" data-copy="moon add moonbitstack/moonapi">copy</button></div><div class="contract"><h2><span class="spark">✶</span> The contract at a glance</h2><pre><span class="k">let</span> app = <span class="ty">App</span>::new() |
122 | 122 | app.get("/users/:id", ctx => text(200, "user " + ctx.param("id").unwrap())) |
123 | 123 |
|
124 | 124 | <span class="k">let</span> spec = app.openapi_json(version=<span class="ty">OpenApi31</span>) // also <span class="ty">OpenApi30</span> / <span class="ty">Swagger20</span> |
|
412 | 412 | <div class="item" data-k="enum"><span class="kind">enum</span><pre class="sig"><span class="k">enum</span> <span class="ty">Dep</span></pre><p class="doc">The dependency value type of the greet app. A sum type wrapping every dependency this app injects — the explicit, exhaustive stand-in for FastAPI resolving heterogeneous <code>Depends</code> values dynamically.</p></div> |
413 | 413 | <div class="item" data-k="fn"><span class="kind">fn</span><pre class="sig"><span class="k">fn</span> greet_app(container : <span class="ty">Container</span>[<span class="ty">Dep</span>]) <span class="op">-></span> <span class="ty">App</span></pre><p class="doc">Build the greet application over a caller-supplied dependency <code>container</code>, so a test can register <code>dependency_overrides</code> on the same container before or between requests. <code>POST /greet</code> resolves the <code>"greeting"</code> dependency, reads a validated <code>GreetReq</code> body, and answers <code>{"message": "<greeting>, <name>"}</code>; a malformed body gets a FastAPI-shaped <code>422</code>. The dependency scope brackets each request, so any <code>yield</code> teardown runs once the handler returns.</p></div> |
414 | 414 | </section> |
415 | | -<footer>Generated from source <code>///</code> doc-comments · <a href="https://mooncakes.io/docs/Lfan-ke/moonapi">mooncakes</a> · <a href="https://github.com/moonbitstack/moonapi">GitHub</a> · Apache-2.0 © Leo Cheng</footer> |
| 415 | +<footer>Generated from source <code>///</code> doc-comments · <a href="https://mooncakes.io/docs/moonbitstack/moonapi">mooncakes</a> · <a href="https://github.com/moonbitstack/moonapi">GitHub</a> · Apache-2.0 © Leo Cheng</footer> |
416 | 416 | </main></div><script> |
417 | 417 | document.addEventListener("DOMContentLoaded",()=>{ |
418 | 418 | document.querySelectorAll("[data-copy]").forEach(btn=>btn.addEventListener("click",()=>{ |
|
0 commit comments