First, we add the latest version of the org.spincast:spincast-default
Maven artifact to our pom.xml (or build.gradle) :
<dependency>
<groupId>org.spincast</groupId>
<artifactId>spincast-default</artifactId>
<version>2.2.0</version>
</dependency>
Then :
public class App {
public static void main(String[] args) {
Spincast.init(args);
}
@Inject
protected void init(DefaultRouter router, Server server) {
router.GET("/").handle(context -> context.response().sendHtml("<h1>Hello World!</h1>"));
server.start();
}
}
Explanation :
(
Tip : try hovering/clicking the page numbers below! )
main(...)
method is the entry point of our application.
Spincast.init(args) will
create a Guice context using the default plugins, will
bind the current App class in the context and will load it.
Route for the index page
using an inline Route Handler based on a lambda.
Download this application, and run it by yourself :
mvn clean package
java -jar target/spincast-demos-quick-2.2.0.jar
The application is then accessible at http://localhost:44419
Try the Better... "Hello World!" demo, for an improved version!