{#========================================== Spincast Request plugin ==========================================#} {% extends "../../layout.html" %} {% block sectionClasses %}plugins hasBreadCrumb plugins-spincast-request{% endblock %} {% block meta_title %}Plugins - Spincast Request{% endblock %} {% block meta_description %}Spincast Request plugin to access information about HTTP requests.{% endblock %} {% block scripts %} {% endblock %} {% block body %}
The Spincast Request plugin provides a Request Context add-on:
RequestRequestContextAddon.
This add-on allows your Route Handlers to get information
about the current HTTP request. It is mounted as .request()
on the default Spincast Request Context.
Make sure you read the section dedicated to the Request Context
for more information on how to use the .request() add-on.
.request() add-on from a Route Handler :
public void myHandler(AppRequestContext context) {
String userId = context.request().getPathParam("userId");
//...
}
If you use the spincast-default artifact, this plugin is already installed so
you have nothing more to do!
If you start from scratch using the spincast-core artifact, you can use the
plugin by adding this artifact to your project:
<dependency>
<groupId>org.spincast</groupId>
<artifactId>spincast-plugins-request</artifactId>
<version>{{spincast.spincastCurrrentVersion}}</version>
</dependency>
You then install the plugin's Guice module, by passing it to the Guice.createInjector(...) method:
Injector guice = Guice.createInjector(
new SpincastCoreGuiceModule(args),
new SpincastRequestPluginGuiceModule(AppRequestContext.class, AppWebsocketContext.class)
// other modules...
);
... or by using the install(...) method from your custom Guice module:
public class AppModule extends SpincastCoreGuiceModule {
@Override
protected void configure() {
super.configure();
install(new SpincastRequestPluginGuiceModule(getRequestContextType(),
getWebsocketContextType()));
// other modules...
}
// ...
}