All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.femo.http.handlers.Handlers Maven / Gradle / Ivy

Go to download

An easy to use HTTP API, that supports synchronous and asynchronous execution of HTTP request. On android only asynchronous driver is supported. This library has been backported to jdk 7 to retain compatibility with android!

The newest version!
package io.femo.http.handlers;

import io.femo.http.HttpHandler;
import io.femo.http.HttpMiddleware;
import io.femo.http.middleware.EnvironmentReplacerMiddleware;
import org.jetbrains.annotations.Contract;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;

/**
 * Created by felix on 6/28/16.
 */
public final class Handlers {

    @Contract("_, _, _ -> !null")
    public static HttpHandler buffered(File source, boolean caching, String mimeType) {
        return FileHandler.buffered(source, caching, mimeType);
    }

    @Contract("_, _, _ -> !null")
    public static HttpHandler resource(String resourceName, boolean caching, String mimeType) {
        return FileHandler.resource(mimeType, caching, resourceName);
    }

    @Contract("_, _, _ -> !null")
    public static HttpHandler directory(File dir, boolean caching, int cacheTime) {
        return new DirectoryFileHandler(dir, caching, cacheTime);
    }

    @Contract("_ -> !null")
    public static HttpMiddleware debug(PrintStream printStream) {
        return new HttpDebugger(printStream);
    }

    @Contract(" -> !null")
    public static HttpMiddleware log() {
        return LoggingHandler.log();
    }

    @Contract(" -> !null")
    public static HttpMiddleware environment() {
        return new EnvironmentReplacerMiddleware();
    }

    @Contract("_, _, _ -> !null")
    public static HttpHandler stream(InputStream inputStream, String mimeType, String eTag) throws IOException {
        return new StreamHandler(mimeType, eTag, inputStream);
    }

    @Contract("_, _, _, _ -> !null")
    public static HttpHandler stream(InputStream inputStream, String mimeType, String eTag, boolean replace) throws IOException {
        return new StreamHandler(mimeType, eTag, inputStream, replace);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy