public class RestApiServlet
extends javax.servlet.http.HttpServlet
Modifier and Type | Class and Description |
---|---|
static class |
RestApiServlet.Globals |
Modifier and Type | Field and Description |
---|---|
static byte[] |
JSON_MAGIC
Garbage prefix inserted before JSON output to prevent XSSI.
|
static java.lang.String |
X_GERRIT_TRACE |
static java.lang.String |
XD_AUTHORIZATION |
static java.lang.String |
XD_CONTENT_TYPE |
static java.lang.String |
XD_METHOD |
Constructor and Description |
---|
RestApiServlet(RestApiServlet.Globals globals,
com.google.inject.Provider<? extends RestCollection<? extends RestResource,? extends RestResource>> members) |
RestApiServlet(RestApiServlet.Globals globals,
RestCollection<? extends RestResource,? extends RestResource> members) |
Modifier and Type | Method and Description |
---|---|
static long |
replyError(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
int statusCode,
java.lang.String msg,
CacheControl c,
java.lang.Throwable err) |
static long |
replyError(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
int statusCode,
java.lang.String msg,
java.lang.Throwable err) |
static long |
replyJson(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
boolean allowTracing,
com.google.common.collect.ListMultimap<java.lang.String,java.lang.String> config,
java.lang.Object result)
Sets a JSON reply on the given HTTP servlet response.
|
protected void |
service(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res) |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
public static final java.lang.String X_GERRIT_TRACE
public static final java.lang.String XD_AUTHORIZATION
public static final java.lang.String XD_CONTENT_TYPE
public static final java.lang.String XD_METHOD
public static final byte[] JSON_MAGIC
This prefix is ")]}'\n" and is designed to prevent a web browser from executing the response body if the resource URI were to be referenced using a <script src="...> HTML tag from another web site. Clients using the HTTP interface will need to always strip the first line of response data to remove this magic header.
public RestApiServlet(RestApiServlet.Globals globals, RestCollection<? extends RestResource,? extends RestResource> members)
public RestApiServlet(RestApiServlet.Globals globals, com.google.inject.Provider<? extends RestCollection<? extends RestResource,? extends RestResource>> members)
protected final void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, java.io.IOException
service
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException
public static long replyJson(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, boolean allowTracing, com.google.common.collect.ListMultimap<java.lang.String,java.lang.String> config, java.lang.Object result) throws java.io.IOException
req
- the HTTP servlet requestres
- the HTTP servlet response on which the reply should be setallowTracing
- whether it is allowed to log the reply if tracing is enabled, must not be
set to true
if the reply may contain sensitive dataconfig
- config parameters for the JSON formattingresult
- the object that should be formatted as JSONjava.io.IOException
public static long replyError(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int statusCode, java.lang.String msg, java.lang.Throwable err) throws java.io.IOException
java.io.IOException
public static long replyError(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int statusCode, java.lang.String msg, CacheControl c, java.lang.Throwable err) throws java.io.IOException
java.io.IOException