Package com.heroku.api

Source Code of com.heroku.api.HttpClientModule

package com.heroku.api;

import com.google.inject.Provides;
import com.heroku.api.connection.FutureConnection;
import com.heroku.api.connection.HttpClientConnection;
import com.heroku.api.exception.RequestFailedException;
import com.heroku.api.parser.JsonSelector;
import com.heroku.api.parser.Parser;

import java.io.IOException;

public class HttpClientModule extends ConnectionTestModule {

    Parser parser;

    public HttpClientModule() {

    }

    public HttpClientModule(Parser p) {
        this.parser = p;
    }

    @Override
    protected void configure() {
        if (parser != null) JsonSelector.selectParser(parser);
    }

    @Provides()
    FutureConnection getConnectionImpl() throws IOException {
        try {
            return new HttpClientConnection();
        } catch (RequestFailedException e) {
            System.out.println(e.getMessage());
            System.out.println(e.getStatusCode());
            System.out.println(e.getResponseBody());
            System.out.flush();
            e.printStackTrace();
            throw e;
        }
    }
}
TOP

Related Classes of com.heroku.api.HttpClientModule

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.