ServiceRoute
A service route: an HTTP route of the module's bounded context whose handler is this function, not a command or a query. The model processor lists it in the context's Manifest (routes), with its parameters and the schemas of its request and response, and generates its binding; the edge mounts it from the Manifest and admits its caller as it admits a query's, so it is a route of the service's contract like any other.
The function is a suspend member of a class the host provides (a bean). Its parameters bind by kind:
a parameter named as a variable of path (
{id}) binds that path segment: aString, anInt, aLong, aDouble, aBooleanor an enum;a RouteQuery parameter binds the query parameter of its name: nullable when it is optional;
a
me.ahoo.wow.api.route.RouteCallparameter is the call: the admitted caller, its scope and the commands it may send;the one other parameter, on a
POST,PUTorPATCH, is the request body.
The return type is the response, written as JSON; Unit answers 204 No Content, and so does a nullable return type when the function returns null, which the Manifest marks responseOptional. A body and a response are a class of their own, or a List, a Set or a Collection of one; a map, a scalar, a bare JsonNode or a stream (a Flow, a Publisher) fails the compilation. A Jackson ObjectNode, a JSON object of any shape, is for a route that relays a body it does not own, such as another service's command: a route of your own takes a class, so its contract is typed. A handler refuses a call by throwing a me.ahoo.wow.api.route.RouteRefusal with one of its errors.
Parameters
the HTTP method.
the path below the context, system-views/{id}: its variables in braces, no reserved segment.
the route's name in the Manifest, its identity for compatibility and its generated client's method; the function's name when empty.
the codes the route refuses with, each a full code (context.code) of an @ErrorCode of the module; the service's merged Manifest refuses one its context does not declare. A code the handler throws that is not listed is still answered, and logged once.