@Rest(allowedMethodParams="OPTIONS") @HtmlDocConfig(navlinks={"up: request:/..","options: servlet:/?method=OPTIONS","stats: servlet:/stats"}) public abstract class BasicRestServlet extends RestServlet implements BasicUniversalRest, BasicRestMethods
RestServlet
with default serializers and parsers defined.
Supports the following request
Accept | Content-Type | Serializer |
---|---|---|
application/json text/json |
application/json | JsonSerializer |
application/json+simple text/json+simple |
application/json | SimpleJsonSerializer |
application/json+schema text/json+schema |
application/json | JsonSchemaSerializer |
text/xml | text/xml | XmlDocSerializer |
text/html | text/html | HtmlDocSerializer |
text/html+stripped | text/html | HtmlStrippedDocSerializer |
text/uon | text/uon | UonSerializer |
application/x-www-form-urlencoded | application/x-www-form-urlencoded | UrlEncodingSerializer |
text/xml+soap | text/xml | SoapXmlSerializer |
text/plain | text/plain | PlainTextSerializer |
Supports the following request
Content-Type | Parser |
---|---|
application/json text/json |
JsonParser |
text/xml application/xml |
XmlParser |
text/html text/html+stripped |
HtmlParser |
text/uon | UonParser |
application/x-www-form-urlencoded | UrlEncodingParser |
text/plain | PlainTextParser |
It should be noted that we do NOT add JsoParser
to the list of parsers since this could cause security
issues.
Use caution when using this particular parser as it could inadvertently cause code execution security holes.
The list of serializers and parsers can be appended to using the
@Rest(serializers)
and
@Rest(parsers)
annotations on subclasses.
This subclass also provides a default OPTIONS page by implementing a getOptions(RestRequest)
that returns a
POJO consisting of beans describing the class.
The OPTIONS page can be modified or augmented by overriding this method and providing your own data.
HtmlDocConfig(stylesheet)
to @Rest(staticFiles)
to {"htdocs:htdocs" ,"styles:styles" }
.
This allows files inside the RestInfoProvider.Null
RestCallLogger.Null
RestResourceResolver.Null
ResourceFinder.Null
BASIC, FUZZY
Constructor and Description |
---|
BasicRestServlet() |
Modifier and Type | Method and Description |
---|---|
void |
error()
[* /error] - Error occurred.
|
Swagger |
getOptions(RestRequest req)
[OPTIONS /*] - Show resource options.
|
Swagger |
getOptions2(RestRequest req)
[GET /options] - Show resource options.
|
RestContextStats |
getStats(RestRequest req)
[GET /stats] - Timing statistics.
|
destroy, doLog, findResource, getContext, getDescription, getMethodDescription, getMethodSummary, getPath, getProperties, getRequest, getResponse, getServletConfig, getSiteName, getSwagger, getTitle, init, isInitialized, log, log, log, log, log, onDestroy, onEndCall, onInit, onPostCall, onPostInit, onPostInitChildFirst, onPreCall, onStartCall, resolve, resolve, service, setContext, setRestResourceResolver
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
getInitParameter, getInitParameterNames, getServletContext, getServletInfo, getServletName, init
public BasicRestServlet()
public Swagger getOptions(RestRequest req)
getOptions
in interface BasicRestMethods
req
- The HTTP request.public Swagger getOptions2(RestRequest req)
getOptions2
in interface BasicRestMethods
req
- The HTTP request.public void error()
Servlet chains will often automatically redirect to
These responses should be left as-is without any additional processing.
error
in interface BasicRestMethods
public RestContextStats getStats(RestRequest req)
Timing statistics for method invocations on this resource.
getStats
in interface BasicRestMethods
req
- The HTTP request.Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.