public class URLMapperHandler extends Object implements HttpServer.Handler
| Constructor and Description |
|---|
URLMapperHandler(HttpServer server,
String basePath,
URL sourceUrl,
boolean includeRelatives)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
URL |
getBaseUrl()
Returns the base URL for this handler.
|
static HttpServer.Response |
mapUrlResponse(String method,
URL targetUrl)
Repackages a resource from a given target URL as an HTTP response.
|
HttpServer.Response |
serveRequest(HttpServer.Request request)
Provides a response to an HTTP request.
|
public URLMapperHandler(HttpServer server, String basePath, URL sourceUrl, boolean includeRelatives) throws MalformedURLException
server - server within which this handler will be usedbasePath - path of served resources relative to the base path
of the server itselfsourceUrl - URL of the resource which is to be made available
at the basePath by this handlerincludeRelatives - if true, relative URLs based at
basePath
may be requested (potentially giving access to
for instance the entire tree of classpath resources);
if false, only the exact resource named by
sourceUrl is servedMalformedURLExceptionpublic URL getBaseUrl()
public HttpServer.Response serveRequest(HttpServer.Request request)
HttpServer.HandlerserveRequest in interface HttpServer.Handlerrequest - HTTP requestpublic static HttpServer.Response mapUrlResponse(String method, URL targetUrl)
method - HTTP methodtargetUrl - URL containing the resource to forwardCopyright © 2008–2024. All rights reserved.