Package org.astrogrid.samp.httpd
Class DirectoryMapperHandler
- java.lang.Object
-
- org.astrogrid.samp.httpd.DirectoryMapperHandler
-
- All Implemented Interfaces:
HttpServer.Handler
public class DirectoryMapperHandler extends java.lang.Object implements HttpServer.Handler
Handler implementation which allows the server to serve a directory full of resources. TheURLMapperHandler
class can sort of do the same thing, but it's difficult to get the path right.For if an instance is initialised as
new DirectoryMapperHandler("/files", "/data")
and installed on a server running athttp://localhost:8000/
, then a server request forhttp://localhost:8000/data/xxx
would be fulfilled by returning the content of the resource/files/xxx
available to the JVM's classloader (for instance within a jar file on the classpath).- Since:
- 11 Mar 2016
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description DirectoryMapperHandler(java.lang.String localDocBase, java.lang.String serverDocPath)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpServer.Response
serveRequest(HttpServer.Request request)
Provides a response to an HTTP request.
-
-
-
Method Detail
-
serveRequest
public HttpServer.Response serveRequest(HttpServer.Request request)
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
-
-