Skip to content

sdorra/web-resources

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web-Resources

Build Status Maven Central Quality Gates Coverage

The web-resources library is usable for serving files over http. It does the following things for you:

  • Detects and set the right Content-Type for the resource
  • Partial caching via Last-Modified, If-Modified-Since and If-Unmodified-Since header
  • Partial caching via ETag, If-Match, If-None-Match header
  • Sets Content-Disposition header
  • Head request without content
  • Optional GZIP compression
  • Optional handling Expires header
  • Optional handling Cache-Control header

Usage

Add the latest stable version of to the dependency management tool of your choice.

E.g. for maven:

<dependency>
    <groupId>com.github.sdorra</groupId>
    <artifactId>web-resources</artifactId>
    <version>x.y.z</version>
</dependency>

Use the latest version from maven central: Maven Central

Example

Path path = Paths.get("myfile.txt");

WebResourceSender.create()
        .withGZIP()
        .withExpires(7, TimeUnit.DAYS)
        .resource(path)
        .send(request, response);

License

This project is licensed under the MIT License - see the LICENSE file for details