java.lang.AutoCloseable
MicroHTTPDService
public interface BasicHTTPService
extends java.lang.AutoCloseable
Modifier and Type | Interface | Description |
---|---|---|
static interface |
BasicHTTPService.BinderHandler |
|
static interface |
BasicHTTPService.FileUpload |
A parameter for
BasicHTTPService.Request.getParams() representing fileupload arguments |
static interface |
BasicHTTPService.Handler |
Handler for HTTP requests.
|
static interface |
BasicHTTPService.Request |
|
static interface |
BasicHTTPService.RequestPreprocessor |
|
static interface |
BasicHTTPService.Response |
HTTP response abstraction
|
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Shutdown the service and free all allocated resources.
|
@Nullable BasicHTTPService.Handler |
on(java.lang.String pathStart,
BasicHTTPService.Handler handler) |
Register request handler which must be called if the
BasicHTTPService.Request.getPath() starts with pathStart. |
@Nullable BasicHTTPService.Handler |
onNotFound(BasicHTTPService.Handler handler) |
Register request handler which must be called if there is no matching
on(String, Handler) requests found. |
void |
start(int port,
int maxResponseThreads) |
Start the service in a separate thread, returns as soon as listening port will be opened.
|
void start(int port, int maxResponseThreads) throws java.io.IOException
port
- is port numbermaxResponseThreads
- is maximum available threadsjava.io.IOException
- if port can't be open for listeningvoid close() throws java.lang.Exception
close
in interface java.lang.AutoCloseable
java.lang.Exception
- for closing exceptions@Nullable BasicHTTPService.Handler on(java.lang.String pathStart, BasicHTTPService.Handler handler)
BasicHTTPService.Request.getPath()
starts with pathStart.pathStart
- the beginning of the request's path that should be handled by this handlerhandler
- to handle such requestsnull
if there were no previous handlers bound to this request
path prefix before this handler;
or BasicHTTPService.Handler
which was bound at this prefix before and that was overwritten.@Nullable BasicHTTPService.Handler onNotFound(BasicHTTPService.Handler handler)
on(String, Handler)
requests found.
By default, if no onNotFound(Handler)
handlers found,
a response with 404 HTTP code and an empty body is returned.
handler
- to handle such requestsnull
if there were no previous handlers bound to this request
path prefix before this handler;
or BasicHTTPService.Handler
which was bound at this prefix before and that was overwritten.