File: //opt/infinispan60/bin/rest/index.html
<!DOCTYPE html>
<!--
~ Copyright 2012-2013 Red Hat, Inc. and/or its affiliates.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this library; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
~ 02110-1301 USA
-->
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<meta content="all" name="robots" />
<title>Infinispan Server: REST Server</title>
<link rel="stylesheet" href="index.css">
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="console.js"></script>
</head>
<body>
<div id="banner">
<h1 class="title">Infinispan Server</h1>
</div>
<div id="main">
<h2>Welcome to the Infinispan Server</h2>
<p>
This server provides easy to use <a
target="info" href="http://en.wikipedia.org/wiki/Representational_State_Transfer">RESTful</a>
access to the Server. See below for usage details.
</p>
<h4>1. Configuration</h4>
<p>
Out of the box, Infinispan Server will use its default cache defined in
<ISPN_HOME>/standalone/configuration/standalone.xml
. To set a custom configuration, modify the configuration file and
restart Infinispan Server
</p>
<p>
Please note that the REST server only allows interaction with either
the default cache, named <em><strong>default</strong></em>
or one of the named caches in the configuration file. This is because
the REST server starts default and pre-defined caches on startup in
order to provide a more consistent behaviour.
</p>
<p>
Please also note that by default the REST server is protected using BASIC HTTP authentication.
You should use the provided <strong>add-user.sh</strong> or <strong>add-user.bat</strong> scripts, depending
on your platform, to add valid users. Alternatively you can configure the <em><strong>security</strong></em> subsystem
for your environment. Refer to the <a target="docs" href="https://docs.jboss.org/author/display/AS7/Security+subsystem+configuration">Security</a>
subsystem documentation for further details.
</p>
<p>
<a target="docs" href="https://docs.jboss.org/author/display/ISPN/Infinispan+REST+Server">The
chapter</a> in the community user guide has more details.
</p>
<h4>2. Putting data in</h4>
<p>
HTTP PUT and POST methods are used to place data in the cache - the
data being the body of the request (the data can be anything you
like). It is important that a
Content-Type
header is set.
</p>
<h6>PUT /rest/{cacheName}/{cacheKey}</h6>
<p>
A PUT request of the above URL form will place the payload (body) in
the given cache, with the given key (if the cache name is new, it
will be automatically initialised). For example
http://someserver/rest/hr/payRoll_3
(in which case
hr
is the cache name, and
payRoll_3
is the key). Any existing data will be replaced, and
Time-To-Live
and
Last-Modified
values will updated (if applicable).
</p>
<h6>POST /rest/{cacheName}/{cacheKey}</h6>
<p>
Exactly the same as PUT, only if a value in a cache/key already
exists, it will return a HTTP
CONFLICT
status (and the content will not be updated).
</p>
<h6>Headers:</h6>
<p>The following HTTP headers are supported:</p>
<table>
<tr>
<th>Header Name</th>
<th>Required?</th>
<th>Description</th>
</tr>
<tr>
<td>Content-Type</td>
<td>Yes</td>
<td>Use <a target="info" href="http://www.iana.org/assignments/media-types/">media/mime-types</a>,
for example "application/json"
</td>
</tr>
<tr>
<td>timeToLiveSeconds</td>
<td>No</td>
<td>The number of seconds before this entry will automatically
be deleted</td>
</tr>
<tr>
<td>maxIdleTimeSeconds</td>
<td>No</td>
<td>The number of seconds after last usage of this entry when
it will automatically be deleted</td>
</tr>
<tr>
<td>performAsync</td>
<td>No</td>
<td>If true, this will return immediately, and then replicate
data to the cluster on its own. Can help with bulk data
inserts/large clusters.</td>
</tr>
</table>
<h4>3. Getting data back out</h4>
<p>HTTP GET and HEAD are used to retrieve data from entries.</p>
<h6>GET /rest/{cacheName}/{cacheKey}</h6>
<p>
This will return the data found in the given cache name, under the
given key - as the body of the response. A
Content-Type
header will be supplied which matches what the data was inserted as.
Browsers can use the cache directly of course (e.g., as a <a
target="info" href="http://en.wikipedia.org/wiki/Content_delivery_network">CDN</a>).
</p>
<p>
An <a target="info" href="http://en.wikipedia.org/wiki/HTTP_ETag">ETag</a> will be
returned unique for each entry, as will the
Last-Modified
header field indicating the state of the data at the given URL. ETags
allow browsers (and other clients) to ask for data only in the case
where it has changed (to save on bandwidth) - this is standard HTTP
and is honored by Infinispan Server.
</p>
<h6>HEAD /rest/{cacheName}/{cacheKey}</h6>
<p>The same as GET, only no content is returned (only the header
fields).</p>
<h4>4. Removing data</h4>
Data can be removed at the cache key/element level, or via a whole
cache name using the HTTP delete method.
<h6>DELETE /rest/{cacheName}/{cacheKey}</h6>
<p>Removes the given key name from the cache.</p>
<h6>DELETE /rest/{cacheName}</h6>
<p>Removes ALL the entries in the given cache name (i.e. everything
from that path down).</p>
<p>
OPTIONAL: Set the header
performAsync
to
true
to return immediately and let the removal happen in the background.
</p>
<h4>5. Clients</h4>
Any HTTP client will do - from any language. See <a
target="docs" href="https://docs.jboss.org/author/display/ISPN/Infinispan+REST+Server">here</a>
for more details.
<h4>6. Deployment</h4>
Infinispan Server is a distributed data grid, it shouldn"t matter
how many or which instance of the Server you access, as long as it is
part of the Infinispan Server cluster, it will find your data, and
manage it. You can have as many instances (including the one you are
looking at) as you need.
</div> <!-- main -->
<div id="console-wrapper">
<a href="#">[+]</a>
<div id="console">
<h2>RESTful Console</h2>
<hr />
<ol id="history"></ol>
<form id="input-form">
<input type="text" id="prompt"/>
<table id="headers">
<tr>
<td><label for="content-type">Content-Type</label></td>
<td><input type="text" id="content-type" value="text/plain"/></td>
<td><label for="perform-async">Async</label></td>
<td><input type="checkbox" id="perform-async"/></td>
</tr>
<tr>
<td><label for="ttl">Time to Live (secs)</label></td><td><input type="number" id="ttl"/></td>
<td><label for="max-idle">Max Idle (secs)</label></td><td><input type="number" id="max-idle"/></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>