03 / EDGE
group
Group registers a set of routes under a shared path prefix, so related endpoints are declared without repeating the prefix.
WHERE IT SITS
INTERFACE
struct GroupstructA 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) -> GroupfnOpen a group that prefixes every route it registers with prefix on app.
fn Group::prefix(self : Group) -> StringfnThe prefix this group joins onto each registered route.
fn Group::options(self : Group) -> RouteOptionsfnThe options every route in this group inherits.
fn Group::options_(self : Group, options : RouteOptions) -> GroupfnA 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) -> GroupfnA sub-group under prefix, inheriting every option.
fn Group::route( self : Group, verb : @moonapi.Method, path : String, handler : @moonapi.ApiHandler, summary~ : String = "") -> UnitfnRegister 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 = "") -> UnitfnRegister a GET route under the group's prefix.
fn Group::post( self : Group, path : String, handler : @moonapi.ApiHandler, summary~ : String = "") -> UnitfnRegister a POST route under the group's prefix.
fn Group::put( self : Group, path : String, handler : @moonapi.ApiHandler, summary~ : String = "") -> UnitfnRegister a PUT route under the group's prefix.
fn Group::patch( self : Group, path : String, handler : @moonapi.ApiHandler, summary~ : String = "") -> UnitfnRegister a PATCH route under the group's prefix.
fn Group::delete( self : Group, path : String, handler : @moonapi.ApiHandler, summary~ : String = "") -> UnitfnRegister a DELETE route under the group's prefix.
fn Group::sse( self : Group, path : String, handler : @moonapi.ApiHandler, summary~ : String = "") -> UnitfnRegister a server-sent-events route: a GET that answers with text/event-stream and is not cached.