Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package io.dropwizard.bundles.assets;
import com.google.common.base.CharMatcher;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheBuilderSpec;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.Weigher;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.common.hash.Hashing;
import com.google.common.io.Files;
import com.google.common.io.Resources;
import com.google.common.net.HttpHeaders;
import com.google.common.net.MediaType;
import io.dropwizard.servlets.assets.ByteRange;
import io.dropwizard.servlets.assets.ResourceURL;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.MimeTypes;
/**
* Servlet responsible for serving assets to the caller. This is basically completely stolen from
* {@link io.dropwizard.servlets.assets.AssetServlet} with the exception of allowing for override
* options.
*
* @see io.dropwizard.servlets.assets.AssetServlet
*/
public class AssetServlet extends HttpServlet {
private static final long serialVersionUID = 6393345594784987908L;
private static final MediaType DEFAULT_MEDIA_TYPE = MediaType.HTML_UTF_8;
private static final CharMatcher SLASHES = CharMatcher.is('/');
private final transient CacheBuilderSpec cacheSpec;
private final transient LoadingCache cache;
private final transient MimeTypes mimeTypes;
private Charset defaultCharset;
private String cacheControlHeader = null;
/**
* Creates a new {@code AssetServlet} that serves static assets loaded from {@code resourceURL}
* (typically a file: or jar: URL). The assets are served at URIs rooted at {@code uriPath}. For
* example, given a {@code resourceURL} of {@code "file:/data/assets"} and a {@code uriPath} of
* {@code "/js"}, an {@code AssetServlet} would serve the contents of {@code
* /data/assets/example.js} in response to a request for {@code /js/example.js}. If a directory
* is requested and {@code indexFile} is defined, then {@code AssetServlet} will attempt to
* serve a file with that name in that directory. If a directory is requested and {@code
* indexFile} is null, it will serve a 404.
*
* @param resourcePathToUriPathMapping A mapping from base URL's from which assets are loaded to
* the URI path fragment in which the requests for that asset
* are rooted
* @param indexFile the filename to use when directories are requested, or null
* to serve no indexes
* @param defaultCharset the default character set
* @param spec the CacheBuilderSpec to use
* @param overrides the path overrides
* @param mimeTypes the mimeType overrides
*/
public AssetServlet(Iterable> resourcePathToUriPathMapping,
String indexFile,
Charset defaultCharset,
CacheBuilderSpec spec,
Iterable> overrides,
Iterable> mimeTypes) {
this.defaultCharset = defaultCharset;
AssetLoader loader = new AssetLoader(resourcePathToUriPathMapping, indexFile, overrides);
CacheBuilder