This plugin provides a add-on
to help building a response to the current HTTP request.
Make sure you read the dedicated Sending the response section for more information.
If you use the spincast-default
artifact and the standard Bootstrapper,
this plugin is already installed by default so you have nothing to do!
If you start from scratch, using the spincast-core
artifact, you can use the
plugin by :
1. Adding this Maven artifact to your project:
<dependency> <groupId>org.spincast</groupId> <artifactId>spincast-plugins-response</artifactId> <version>2.2.0</version> </dependency>
2. Installing the provided SpincastResponsePluginModule module to your Guice context.
The class implementing the SpincastPlugin interface is SpincastResponsePlugin.
response()
Examples :
public void myHandler(AppRequestContext context) { context.response().setStatusCode(418); context.response().sendPlainText("Drink tea!"); }
response model
and render HTML
using a template :
public void myHandler(AppRequestContext context) { //... context.response().getModel().set("user", someUser); context.response().sendTemplateHtml("/templates/user.html"); }
This add-on is already installed by default on the Request Context type.