public class ResourceRestEndpoint extends RestEndpoint
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
resource
Path to embedded resource to serve.
|
uri| Constructor and Description |
|---|
ResourceRestEndpoint(java.lang.String uri,
java.lang.String resource)
Creates a static resource end-point that responds to given URI and serves given resource.
|
ResourceRestEndpoint(java.lang.String uri,
java.lang.String resource,
java.lang.String mimetype)
Creates a static resource end-point that responds to given URI and serves given resource.
|
| Modifier and Type | Method and Description |
|---|---|
ej.hoka.http.HTTPResponse |
get(ej.hoka.http.HTTPRequest request,
java.util.Map<java.lang.String,java.lang.String> headers,
java.util.Map<java.lang.String,java.lang.String> parameters)
Handles
GET request on this endpoint. |
java.lang.String |
getMimetype()
Gets the mimetype.
|
protected java.io.InputStream |
getResourceAsStream()
Gets the resource to serve as an input stream.
|
protected ej.hoka.http.HTTPResponse |
getResourceResponse()
Gets the resource to serve as an HTTP response.
|
void |
setMimetype(java.lang.String mimetype)
Sets the mimetype.
|
delete, getURI, post, putpublic ResourceRestEndpoint(java.lang.String uri,
java.lang.String resource)
uri - the end-point URI, cannot be null.resource - the resource to serve, cannot be null.public ResourceRestEndpoint(java.lang.String uri,
java.lang.String resource,
java.lang.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)protected java.io.InputStream getResourceAsStream()
null if resource is not found.protected ej.hoka.http.HTTPResponse getResourceResponse()
application/octet-stream content type.MIMEUtils.MIME_DEFAULT_BINARYpublic ej.hoka.http.HTTPResponse get(ej.hoka.http.HTTPRequest request,
java.util.Map<java.lang.String,java.lang.String> headers,
java.util.Map<java.lang.String,java.lang.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 java.lang.String getMimetype()
null.public void setMimetype(java.lang.String mimetype)
mimetype - the mimetype to set, if null, the type will be computed.MIMEUtils.getMIMEType(String)