templates.plugins.spincast-response.spincast-response.html Maven / Gradle / Ivy
Show all versions of spincast-website Show documentation
{% extends "../../layout.html" %}
{% block sectionClasses %}plugins hasBreadCrumb plugins-spincast-response{% endblock %}
{% block meta_title %}Plugins - Spincast Response{% endblock %}
{% block meta_description %}Spincast Response plugin to manipulate the headers and content sent.{% endblock %}
{% block scripts %}
{% endblock %}
{% block body %}
Overview
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.
Installation
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>{{spincast.spincastCurrrentVersion}}</version>
</dependency>
2. Installing the provided SpincastResponsePluginModule
module to your Guice context.
Plugin class
The class implementing the SpincastPlugin
interface is SpincastResponsePlugin.
Suggested add-on
-
Name :
response()
-
Component : ResponseRequestContextAddon
-
Usage : to help building a response to the current HTTP request. It allows you to manipulate the
HTTP headers and provides utilities to build the body.
Examples :
-
Sending content directly :
public void myHandler(AppRequestContext context) {
context.response().setStatusCode(418);
context.response().sendPlainText("Drink tea!");
}
-
Building the
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.
Javadoc
{% endblock %}