Package org.takes.tk

Class TkFiles

  • All Implemented Interfaces:
    Take

    public final class TkFiles
    extends TkWrap
    Take reading resources from directory.

    This "take" is trying to find the requested resource in file system and return it as an HTTP response with binary body, for example:

     new TkFiles("/tmp");

    This object will take query part of the arrived HTTP Request and concatenate it with the "/tmp" prefix. For example, a request comes it and its query equals to "/css/style.css?eot". TkFiles will try to find a resource "/tmp/css/style.css" on disc.

    If such a resource is not found, HttpException will be thrown.

    The class is immutable and thread-safe.

    Since:
    0.1
    • Constructor Detail

      • TkFiles

        public TkFiles​(String base)
        Ctor.
        Parameters:
        base - Base directory
      • TkFiles

        public TkFiles​(File base)
        Ctor.
        Parameters:
        base - Base directory