public class ResourceRestEndpoint extends RestEndpoint
| Modifier and Type | Field and Description |
|---|---|
protected String |
resource
Path to embedded resource to serve.
|
uri| Constructor and Description |
|---|
ResourceRestEndpoint(String uri,
String resource)
Creates a static resource end-point that responds to given URI and serves given resource.
|
ResourceRestEndpoint(String uri,
String resource,
String mimetype)
Creates a static resource end-point that responds to given URI and serves given resource.
|
| Modifier and Type | Method and Description |
|---|---|
HTTPResponse |
get(HTTPRequest request,
Map<String,String> headers,
Map<String,String> parameters)
Handles
GET request on this endpoint. |
String |
getMimetype()
Gets the mimetype.
|
protected InputStream |
getResourceAsStream()
Gets the resource to serve as an input stream.
|
protected HTTPResponse |
getResourceResponse()
Gets the resource to serve as an HTTP response.
|
void |
setMimetype(String mimetype)
Sets the mimetype.
|
delete, getURI, post, putprotected String resource
public ResourceRestEndpoint(String uri, String resource)
uri - the end-point URI, cannot be null.resource - the resource to serve, cannot be null.public ResourceRestEndpoint(String uri, String resource, String mimetype)
uri - the end-point URI, cannot be null.resource - the resource to serve, cannot be null.mimetype - the mime type of the resource, if null, the mimetype will be computed.MIMEUtils#getMIMEType(String)public HTTPResponse get(HTTPRequest request,
Map<String,String> headers,
Map<String,String> parameters)
RestEndpointGET request on this endpoint.
Default implementation return a a status code 501
get in class RestEndpointrequest - the request to handle.headers - request headers.parameters - parsed query and body parameters.public String getMimetype()
null.protected InputStream getResourceAsStream()
null if resource is not found.protected HTTPResponse getResourceResponse()
application/octet-stream content type.MIMEUtils#MIME_DEFAULT_BINARYpublic void setMimetype(String mimetype)
mimetype - the mimetype to set, if null, the type will be computed.MIMEUtils#getMIMEType(String)