/** * Defines a ZIP resource on the classpath that provides the static content the server should host. * @param contextRoot * the root path to the content * @param contentResource * the name of the classpath resource denoting a file that should be hosted. If the file denotes a zip file, its * content is hosted instead of the file itself. * The path may be absolute or relative to the caller of the method. * @return * this builder */ public HttpServerBuilder contentFrom(String contextRoot, String contentResource){ URL resource = resolver.resolve(contentResource,CallStack.getCallerClass()); resources.put(contextRoot, resource); return this; }
/** * Defines the classpath resource from where the content of the file should be retrieved * * @param pathToResource * the path to the classpath resource * @return the builder */ public TemporaryFileBuilder fromClasspathResource(final String pathToResource) { final Class<?> callerClass = CallStack.getCallerClass(); this.content = getResolver().resolve(pathToResource, callerClass); return this; }
/** * Adds an entry to the zip file from a classpath resource. * * @param zipEntryPath * the path of the entry in the zip file. If the path denotes a path (ends with '/') the resource is put * under its own name on that location. If it denotes a file, it will be put as this file into the zip. Note * that even if the path ist defined absolute, starting with a '/', the created entry in the zip file won't * start with a '/' * @param pathToResource * the path to the resource in the classpath * * @return this builder */ public ZipFileBuilder addClasspathResource(final String zipEntryPath, final String pathToResource) { final Class<?> callerClass = getCallerClass(); final URL resource = resolver.resolve(pathToResource, callerClass); addResource(zipEntryPath, resource); return this; }