public class MultiURLMapperHandler extends java.lang.Object implements HttpServer.Handler
The functionality of this class overlaps with that of
URLMapperHandler
. They may be merged at some point.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
basePath_ |
private java.net.URL |
baseUrl_ |
private int |
resourceCount_ |
private HttpServer |
server_ |
private java.util.Map |
urlMap_ |
Constructor and Description |
---|
MultiURLMapperHandler(HttpServer server,
java.lang.String basePath)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.net.URL |
addLocalUrl(java.net.URL localUrl)
Adds a local URL to the list of those which can be served by this
handler, and returns the public URL at which it will be available.
|
java.net.URL |
getBaseUrl()
Returns the base URL for resources served by this handler.
|
void |
removeServerUrl(java.net.URL url)
Removes access to a resource which was publicised by a previous call
to
addLocalUrl(java.net.URL) . |
HttpServer.Response |
serveRequest(HttpServer.Request request)
Provides a response to an HTTP request.
|
private final HttpServer server_
private final java.lang.String basePath_
private final java.net.URL baseUrl_
private final java.util.Map urlMap_
private int resourceCount_
public MultiURLMapperHandler(HttpServer server, java.lang.String basePath) throws java.net.MalformedURLException
server
- server within which this handler will be usedbasePath
- path of served resources relative to the base
URL of the server itselfjava.net.MalformedURLException
public java.net.URL getBaseUrl()
public java.net.URL addLocalUrl(java.net.URL localUrl)
localUrl
- URL readable within this JVMlocalUrl
public void removeServerUrl(java.net.URL url)
addLocalUrl(java.net.URL)
.url
- result of previous call to addLocalUrl
public HttpServer.Response serveRequest(HttpServer.Request request)
HttpServer.Handler
serveRequest
in interface HttpServer.Handler
request
- HTTP request