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

com.codingapi.springboot.framework.rest.HttpClient Maven / Gradle / Ivy

The newest version!
package com.codingapi.springboot.framework.rest;

import com.alibaba.fastjson.JSON;
import com.codingapi.springboot.framework.rest.properties.HttpProxyProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.util.MultiValueMap;

@Slf4j
public class HttpClient {

    private final HttpRequest httpRequest;

    public HttpClient() {
        this.httpRequest = new HttpRequest();
    }

    public HttpClient(HttpRequest.IHttpRequestHandler requestHandler, HttpRequest.IHttpResponseHandler responseHandler) {
        this.httpRequest = new HttpRequest(requestHandler,responseHandler);
    }

    public HttpClient(HttpProxyProperties properties) {
        this.httpRequest = new HttpRequest(properties);
    }

    public HttpClient(HttpProxyProperties properties, HttpRequest.IHttpRequestHandler requestHandler, HttpRequest.IHttpResponseHandler responseHandler) {
        this.httpRequest = new HttpRequest(properties, requestHandler, responseHandler);
    }

    public String post(String url, HttpHeaders headers, JSON jsonObject) {
        return httpRequest.getPostRequest(url, headers, jsonObject).execute();
    }

    public String post(String url, HttpHeaders headers, MultiValueMap formData) {
        return httpRequest.getPostRequest(url, headers, formData).execute();
    }

    public String get(String url, HttpHeaders headers, MultiValueMap uriVariables) {
        return httpRequest.getGetRequest(url, headers, uriVariables).execute();
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy