@RestResource(allowedMethodParams="OPTIONS", htmldoc=) public abstract class BasicRestServlet extends RestServlet implements BasicRestConfig
RestServlet
with default serializers and parsers defined.
Supports the following request Accept
header values with the resulting response Content-Type
:
Accept | Content-Type | Serializer |
---|---|---|
application/json text/json |
application/json | JsonSerializer |
application/json+simple text/json+simple |
application/json | JsonSerializer.Simple |
application/json+schema text/json+schema |
application/json | JsonSchemaSerializer |
text/xml | text/xml | XmlDocSerializer |
text/xml+schema | text/xml | XmlSchemaDocSerializer |
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
header values:
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
@RestResource.serializers()
and
@RestResource.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.
@HtmlDoc.stylesheet()
to @RestResource.staticFiles()
to {"htdocs:htdocs" ,"styles:styles" }
.
This allows files inside the [servletPackage].htdocs
package to be served up under the URL
/servletPath/htdocs
.
Constructor and Description |
---|
BasicRestServlet() |
Modifier and Type | Method and Description |
---|---|
Swagger |
getOptions(RestRequest req)
[OPTIONS /*] - Show resource options.
|
destroy, getContext, getProperties, getServletConfig, init, log, log, log, log, logObjects, service
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
public BasicRestServlet()
@RestMethod(name="OPTIONS", path="/*", htmldoc=, summary="Swagger documentation", description="Auto-generated swagger documentation for this resource") public Swagger getOptions(RestRequest req)
req
- The HTTP request.Copyright © 2018 Apache. All rights reserved.