Routes and Actions
Express request handling and asynchronous results with Java methods.
Declare a handler
HelloWorldAction uses Spring @Controller and a class-level @RouteMapping("hello"). Methods declare routes such as @RouteMapping("sayHello"). The example extends ControllerSupport and builds results with ok().withBody(...).
Synchronous and asynchronous results
Request handlers can return Result or CompletionStage
import org.springframework.stereotype.Controller;
import io.nextrix.framework.Result;
import io.nextrix.framework.support.ControllerSupport;
import io.nextrix.framework.config.annotation.RouteMapping;
@Controller
@RouteMapping("hello")
public class HelloWorldAction extends ControllerSupport {
@RouteMapping("sayHello")
public Result sayHello(String content) {
return ok().withBody("content=hi!");
}
}Arguments and readability
Examples include Session, @RequestHeader arguments, and FrameStream. The excerpt below keeps one route and omits logging and other methods. Refer to the source for complete argument handling and configuration.
Source reference
This guide is based on the following source or module documentation. Repository access is required.
nextrix-j/nextrix-examples/nextrix-example-app/src/main/java/io/nextrix/example/demo/helloworld/action/HelloWorldAction.java