Package org.astrogrid.samp.httpd
Class MultiURLMapperHandler
java.lang.Object
org.astrogrid.samp.httpd.MultiURLMapperHandler
- All Implemented Interfaces:
HttpServer.Handler
Handler implementation which allows the server to serve multiple
separate resources which are available to it, but not necessarily to
external clients, as URLs. The main use for this is if the URLs
are jar:-type ones (not available to clients outside the current JVM)
or file:-type ones (not available to clients on different hosts).
Only single resources, not whole trees, can be exported in this way.
The functionality of this class overlaps with that of
URLMapperHandler
. They may be merged at some point.
- Since:
- 21 Jul 2009
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddLocalUrl
(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.Returns the base URL for resources served by this handler.void
removeServerUrl
(URL url) Removes access to a resource which was publicised by a previous call toaddLocalUrl(java.net.URL)
.serveRequest
(HttpServer.Request request) Provides a response to an HTTP request.
-
Constructor Details
-
MultiURLMapperHandler
Constructor.- Parameters:
server
- server within which this handler will be usedbasePath
- path of served resources relative to the base URL of the server itself- Throws:
MalformedURLException
-
-
Method Details
-
getBaseUrl
Returns the base URL for resources served by this handler.- Returns:
- base URL for output
-
addLocalUrl
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.- Parameters:
localUrl
- URL readable within this JVM- Returns:
- URL readable in principle by external agents with the same
content as
localUrl
-
removeServerUrl
Removes access to a resource which was publicised by a previous call toaddLocalUrl(java.net.URL)
.- Parameters:
url
- result of previous call toaddLocalUrl
-
serveRequest
Description copied from interface:HttpServer.Handler
Provides a response to an HTTP request. A handler which does not recognise the URL should simply return null; in this case there may be another handler which is able to serve the request. If the URL appears to be in this handler's domain but the request cannot be served for some reason, an error response should be returned.- Specified by:
serveRequest
in interfaceHttpServer.Handler
- Parameters:
request
- HTTP request- Returns:
- response response to request, or null
-