Class HTTPServer.StaticPageHandler
java.lang.Object
ch.autumo.beetroot.server.HTTPServer.DefaultStreamHandler
ch.autumo.beetroot.server.HTTPServer.DefaultHandler
ch.autumo.beetroot.server.HTTPServer.StaticPageHandler
- All Implemented Interfaces:
HTTPServer.UriResponder
- Enclosing class:
HTTPServer
Serves static files from a directory that is passed as init parameter.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected BufferedInputStreamfileToInputStream(File fileOrdirectory) Opens the given file as a buffered input stream.org.nanohttpd.protocols.http.response.Responseget(HTTPServer.UriResource uriResource, Map<String, String> urlParams, org.nanohttpd.protocols.http.IHTTPSession session) Handles an HTTP GET request.Not supported; the MIME type is derived from the file name.org.nanohttpd.protocols.http.response.IStatusHTTP status of the response.getText()Not supported; static pages are read from the file system.Methods inherited from class HTTPServer.DefaultHandler
getDataMethods inherited from class HTTPServer.DefaultStreamHandler
delete, other, post, putModifier and TypeMethodDescriptionorg.nanohttpd.protocols.http.response.Responsedelete(HTTPServer.UriResource uriResource, Map<String, String> urlParams, org.nanohttpd.protocols.http.IHTTPSession session) Handles an HTTP DELETE request.org.nanohttpd.protocols.http.response.Responseother(String method, HTTPServer.UriResource uriResource, Map<String, String> urlParams, org.nanohttpd.protocols.http.IHTTPSession session) Handles any other HTTP method.org.nanohttpd.protocols.http.response.Responsepost(HTTPServer.UriResource uriResource, Map<String, String> urlParams, org.nanohttpd.protocols.http.IHTTPSession session) Handles an HTTP POST request.org.nanohttpd.protocols.http.response.Responseput(HTTPServer.UriResource uriResource, Map<String, String> urlParams, org.nanohttpd.protocols.http.IHTTPSession session) Handles an HTTP PUT request.
-
Constructor Details
-
StaticPageHandler
public StaticPageHandler()Default constructor.
-
-
Method Details
-
getText
Not supported; static pages are read from the file system.- Specified by:
getTextin classHTTPServer.DefaultHandler- Returns:
- never returns
- Throws:
IllegalStateException- always
-
getMimeType
Not supported; the MIME type is derived from the file name.- Specified by:
getMimeTypein classHTTPServer.DefaultStreamHandler- Returns:
- never returns
- Throws:
IllegalStateException- always
-
getStatus
public org.nanohttpd.protocols.http.response.IStatus getStatus()Description copied from class:HTTPServer.DefaultHandlerHTTP status of the response.- Specified by:
getStatusin classHTTPServer.DefaultHandler- Returns:
- the response status
-
get
public org.nanohttpd.protocols.http.response.Response get(HTTPServer.UriResource uriResource, Map<String, String> urlParams, org.nanohttpd.protocols.http.IHTTPSession session) Description copied from interface:HTTPServer.UriResponderHandles an HTTP GET request.- Specified by:
getin interfaceHTTPServer.UriResponder- Overrides:
getin classHTTPServer.DefaultHandler- Parameters:
uriResource- the route that matched the requesturlParams- the parameters extracted from the URIsession- the HTTP session- Returns:
- the response
-
fileToInputStream
Opens the given file as a buffered input stream.- Parameters:
fileOrdirectory- the file to open- Returns:
- the buffered input stream
- Throws:
IOException- if the file cannot be read
-