This distribution of Piranha is the smallest in our lineup and it delivers you with a very opinionated embeddable partial implementation of a Servlet container. While very small it most certainly is very capable and it is very easy to use.
NanoPiranha piranha = new NanoPiranhaBuilder() .servlet("TestHelloWorldServlet", new TestHelloWorldServlet()) .build(); NanoRequest request = new NanoRequestBuilder() .method("GET") .servletPath("/index.html") .build(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); NanoResponse response = new NanoResponseBuilder() .outputStream(outputStream) .build(); piranha.service(request, response);
The example above adds the
TestHelloWorldServlet to Piranha Nano. It creates
GET request at path
index.html and it creates a response with a
ByteArrayOutputStream as it output stream. And it then asks Piranha Nano to
Please use the following dependency.
<dependency> <groupId>cloud.piranha</groupId> <artifactId>piranha-nano</artifactId> <version>y.m.p</version> </dependency>
y is the year,
m is the month and
p is the patch version of the
release you want to use.
See GitHub at https://github.com/piranhacloud/piranha/tree/master/nano