moonzero · control plane v0.15.0 · 49 packages · 4 targets · Apache-2.0 docs / edge / group GitHub

03 / EDGE

group

Group registers a set of routes under a shared path prefix, so related endpoints are declared without repeating the prefix.

struct Group

structA route group: registers a set of routes on an underlying moonapi.App under a shared path prefix and a shared set of route options, so related endpoints (everything under /api/v1, say) are declared without repeating either.

fn Group::new(app : @moonapi.App, prefix : String) -> Group

fnOpen a group that prefixes every route it registers with prefix on app.

fn Group::prefix(self : Group) -> String

fnThe prefix this group joins onto each registered route.

fn Group::options(self : Group) -> RouteOptions

fnThe options every route in this group inherits.

fn Group::options_(self : Group, options : RouteOptions) -> Group

fnA group that keeps this one's prefix and app with options in place of the inherited set. The prefixes still join, so Group::new(app, "/api").options_(RouteOptions::new().under("/v1")) serves /api/v1/....

fn Group::sub(self : Group, prefix : String) -> Group

fnA sub-group under prefix, inheriting every option.

fn Group::route( self : Group, verb : @moonapi.Method, path : String, handler : @moonapi.ApiHandler, summary~ : String = "") -> Unit

fnRegister a route for an explicit method under the group's prefix and options.

fn Group::get( self : Group, path : String, handler : @moonapi.ApiHandler, summary~ : String = "") -> Unit

fnRegister a GET route under the group's prefix.

fn Group::post( self : Group, path : String, handler : @moonapi.ApiHandler, summary~ : String = "") -> Unit

fnRegister a POST route under the group's prefix.

fn Group::put( self : Group, path : String, handler : @moonapi.ApiHandler, summary~ : String = "") -> Unit

fnRegister a PUT route under the group's prefix.

fn Group::patch( self : Group, path : String, handler : @moonapi.ApiHandler, summary~ : String = "") -> Unit

fnRegister a PATCH route under the group's prefix.

fn Group::delete( self : Group, path : String, handler : @moonapi.ApiHandler, summary~ : String = "") -> Unit

fnRegister a DELETE route under the group's prefix.

fn Group::sse( self : Group, path : String, handler : @moonapi.ApiHandler, summary~ : String = "") -> Unit

fnRegister a server-sent-events route: a GET that answers with text/event-stream and is not cached.