spaceship_helm
Types
pub type App {
App(
get: List(types.Route),
post: List(types.Route),
put: List(types.Route),
delete: List(types.Route),
patch: List(types.Route),
head: List(types.Route),
options: List(types.Route),
custom: dict.Dict(String, List(types.Route)),
not_found: fn(types.Context) -> response.Response(BitArray),
middleware: List(
fn(
types.Context,
fn(types.Context) -> response.Response(BitArray),
) -> response.Response(BitArray),
),
async_get: List(types.AsyncRoute),
async_post: List(types.AsyncRoute),
async_put: List(types.AsyncRoute),
async_delete: List(types.AsyncRoute),
async_patch: List(types.AsyncRoute),
async_head: List(types.AsyncRoute),
async_options: List(types.AsyncRoute),
async_custom: dict.Dict(String, List(types.AsyncRoute)),
async_not_found: fn(types.Context) -> promise.Promise(
response.Response(BitArray),
),
async_middleware: List(
fn(
types.Context,
fn(types.Context) -> promise.Promise(
response.Response(BitArray),
),
) -> promise.Promise(response.Response(BitArray)),
),
extra: dict.Dict(String, dynamic.Dynamic),
)
}
Constructors
-
App( get: List(types.Route), post: List(types.Route), put: List(types.Route), delete: List(types.Route), patch: List(types.Route), head: List(types.Route), options: List(types.Route), custom: dict.Dict(String, List(types.Route)), not_found: fn(types.Context) -> response.Response(BitArray), middleware: List( fn( types.Context, fn(types.Context) -> response.Response(BitArray), ) -> response.Response(BitArray), ), async_get: List(types.AsyncRoute), async_post: List(types.AsyncRoute), async_put: List(types.AsyncRoute), async_delete: List(types.AsyncRoute), async_patch: List(types.AsyncRoute), async_head: List(types.AsyncRoute), async_options: List(types.AsyncRoute), async_custom: dict.Dict(String, List(types.AsyncRoute)), async_not_found: fn(types.Context) -> promise.Promise( response.Response(BitArray), ), async_middleware: List( fn( types.Context, fn(types.Context) -> promise.Promise( response.Response(BitArray), ), ) -> promise.Promise(response.Response(BitArray)), ), extra: dict.Dict(String, dynamic.Dynamic), )
Values
pub fn async_delete(
app: App,
path: String,
handler: fn(types.Context) -> promise.Promise(
response.Response(BitArray),
),
) -> App
Register an asynchronous DELETE route.
pub fn async_get(
app: App,
path: String,
handler: fn(types.Context) -> promise.Promise(
response.Response(BitArray),
),
) -> App
Register an asynchronous GET route.
pub fn async_middleware(
app: App,
mw: fn(
types.Context,
fn(types.Context) -> promise.Promise(
response.Response(BitArray),
),
) -> promise.Promise(response.Response(BitArray)),
) -> App
Add asynchronous middleware.
pub fn async_not_found(
app: App,
handler: fn(types.Context) -> promise.Promise(
response.Response(BitArray),
),
) -> App
Set the asynchronous not-found handler.
pub fn async_on(
app: App,
method: String,
path: String,
handler: fn(types.Context) -> promise.Promise(
response.Response(BitArray),
),
) -> App
Register an asynchronous route with a custom method.
pub fn async_post(
app: App,
path: String,
handler: fn(types.Context) -> promise.Promise(
response.Response(BitArray),
),
) -> App
Register an asynchronous POST route.
pub fn async_put(
app: App,
path: String,
handler: fn(types.Context) -> promise.Promise(
response.Response(BitArray),
),
) -> App
Register an asynchronous PUT route.
pub fn delete(
app: App,
path: String,
handler: fn(types.Context) -> response.Response(BitArray),
) -> App
Register a DELETE route
pub fn get(
app: App,
path: String,
handler: fn(types.Context) -> response.Response(BitArray),
) -> App
Register a GET route
pub fn group(
app: App,
prefix: String,
routes: fn(App) -> App,
) -> App
Group routes under a prefix
pub fn head(
app: App,
path: String,
handler: fn(types.Context) -> response.Response(BitArray),
) -> App
Register a HEAD route
pub fn middleware(
app: App,
mw: fn(
types.Context,
fn(types.Context) -> response.Response(BitArray),
) -> response.Response(BitArray),
) -> App
Add global middleware
pub fn not_found(
app: App,
handler: fn(types.Context) -> response.Response(BitArray),
) -> App
Set custom not-found handler
pub fn on(
app: App,
method: String,
path: String,
handler: fn(types.Context) -> response.Response(BitArray),
) -> App
Register a route with custom method
pub fn options(
app: App,
path: String,
handler: fn(types.Context) -> response.Response(BitArray),
) -> App
Register an OPTIONS route
pub fn patch(
app: App,
path: String,
handler: fn(types.Context) -> response.Response(BitArray),
) -> App
Register a PATCH route
pub fn post(
app: App,
path: String,
handler: fn(types.Context) -> response.Response(BitArray),
) -> App
Register a POST route
pub fn put(
app: App,
path: String,
handler: fn(types.Context) -> response.Response(BitArray),
) -> App
Register a PUT route
pub fn to_fetch(
app: App,
) -> fn(request.Request(BitArray)) -> response.Response(BitArray)
Convert app to a fetch handler for JS runtimes
pub fn to_fetch_async(
app: App,
) -> fn(request.Request(BitArray)) -> promise.Promise(
response.Response(BitArray),
)
Convert an app with asynchronous routes to a Fetch-style handler.
pub fn with(app: App, key: String, value: dynamic.Dynamic) -> App
Add extra data to app context (e.g., env for Cloudflare Workers)