public interface FileRenderer extends Renderer<Path>
An implementation of this is always provided by Ratpack core.
Example usage:
import ratpack.handling.Handler; import ratpack.handling.Context; import java.nio.file.Path; public class FileRenderingHandler implements Handler { public void handle(Context context) { Path file = context.file("some/file/to/serve.txt"); context.render(file); } }
Use of this renderer should be preferred over Response.sendFile(ratpack.handling.Background, java.nio.file.Path)
as it handles
HTTP Caching by way of the If-Modified-Since
header,
based on timestamps reported by the filesystem.
If the Response.contentType(String)
has not been set prior to calling this method,
it will be guessed by retrieving the MimeTypes
from the context and using it to calculate the type
based on the name of the file.