{"id":15669705,"url":"https://github.com/deveth0/httpclient-spring-boot-starter","last_synced_at":"2025-05-06T20:21:39.018Z","repository":{"id":48487734,"uuid":"261140849","full_name":"deveth0/httpclient-spring-boot-starter","owner":"deveth0","description":"Spring Boot Starter to configure the Apache and Ok HttpClients","archived":false,"fork":false,"pushed_at":"2021-07-23T04:42:47.000Z","size":153,"stargazers_count":4,"open_issues_count":6,"forks_count":5,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-31T02:34:26.687Z","etag":null,"topics":["feign","httpclient","proxy","resttemplate","spring","spring-boot"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deveth0.png","metadata":{"files":{"readme":"README.md","changelog":"changes.xml","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-04T10:14:56.000Z","updated_at":"2024-07-30T21:17:46.000Z","dependencies_parsed_at":"2022-09-26T22:01:23.039Z","dependency_job_id":null,"html_url":"https://github.com/deveth0/httpclient-spring-boot-starter","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deveth0%2Fhttpclient-spring-boot-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deveth0%2Fhttpclient-spring-boot-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deveth0%2Fhttpclient-spring-boot-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deveth0%2Fhttpclient-spring-boot-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deveth0","download_url":"https://codeload.github.com/deveth0/httpclient-spring-boot-starter/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252761762,"owners_count":21800205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["feign","httpclient","proxy","resttemplate","spring","spring-boot"],"created_at":"2024-10-03T14:40:52.652Z","updated_at":"2025-05-06T20:21:38.996Z","avatar_url":"https://github.com/deveth0.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# httpclient-spring-boot-starter\n\n[![Build Status](https://travis-ci.com/deveth0/httpclient-spring-boot-starter.svg)](https://travis-ci.com/github/deveth0/httpclient-spring-boot-starter)\n![Code scanning - action](https://github.com/deveth0/httpclient-spring-boot-starter/workflows/Code%20scanning%20-%20action/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/deveth0/httpclient-spring-boot-starter/badge.svg?branch=master)](https://coveralls.io/github/deveth0/httpclient-spring-boot-starter?branch=master)\n[![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/de.dev-eth0.spring-boot.httpclient/httpclient-spring-boot-starter?color=brightgreen\u0026label=release\u0026server=https%3A%2F%2Foss.sonatype.org)](https://oss.sonatype.org/content/repositories/releases/de/dev-eth0/spring-boot/httpclient/httpclient-spring-boot-starter/)\n[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/de.dev-eth0.spring-boot.httpclient/httpclient-spring-boot-starter?color=brightgreen\u0026label=snapshot\u0026server=https%3A%2F%2Foss.sonatype.org)](https://oss.sonatype.org/content/repositories/snapshots/de/dev-eth0/spring-boot/httpclient/httpclient-spring-boot-starter/)\n[![License](https://img.shields.io/github/license/deveth0/httpclient-spring-boot-starter?color=brightgreen)](http://www.apache.org/licenses/LICENSE-2.0.html)\n\nThis project provides a Spring-Boot Starter that enables the additional configuration of the used Httpclients. \n\nIt supports the configuration of [OkHttp](https://square.github.io/okhttp/) and [Apache HttpClient](https://hc.apache.org/httpcomponents-client-ga/) which are also the supported Clients in Spring.\n\n## Usage\n\nThe `httpclient-spring-boot-starter` brings most of the required configuration with it, therefor you only need to add it as a maven dependency and enable the desired Httpclient.\n \n```\n\u003cdependency\u003e\n  \u003cgroupId\u003ede.dev-eth0.spring-boot.httpclient\u003c/groupId\u003e\n  \u003cartifactId\u003ehttpclient-spring-boot-starter\u003c/artifactId\u003e\n  \u003cversion\u003eLATEST-VERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nMake sure, that you have either `org.apache.httpcomponents:httpclient` or `com.squareup.okhttp3:okhttp` declared as a dependency and enable the configuration as described in [spring-cloud-commons - http-clients](https://cloud.spring.io/spring-cloud-commons/reference/html/#http-clients).\n\nThis will make sure, that the `spring-cloud` dependencies use the custom client configurations.\n \n### Feign\n\nFeign uses a different configuration to enable the clients: `feign.okhttp.enabled` and `feign.httpclient.enabled`. \n\n### RestTemplate\n\nTo make sure, your RestTemplate uses the custom client, you need to configure it accordingly:\n```\n@Bean\npublic RestTemplate restTemplate(RestTemplateBuilder builder, ClientHttpRequestFactory clientHttpRequestFactory) {\n  return builder.requestFactory(() -\u003e clientHttpRequestFactory).build();\n}\n```\n\n## Configuration \n\nAll configuration values are prefixed with `http.client` (e.g. `http.client.timeouts.connectionTimeout`).\n\nIt's possible to configure the proxy based on the requested hostnames using the `hostPattern` config.\n\n| Config | Description | Default | Example | \n|---|---|---|---|\n| sslContext | SSL Version (optional) | `TLSv1.2` | `TLSv1.3` |\n| timeouts.connectionTimeout (optional) | Connection Timeout in ms  | 5000 |  |\n| timeouts.socketTimeout (optional) |  Socket Timeout in ms, for OkHttp this is used as readTimeout and writeTimeout | 10000  |\n| proxies[] (optional) | Configuration for used proxy servers | | |\n| proxies[].hostPatterns | Pattern for matching the hostname, empty matches all  | empty | `google.*`  |\n| proxies[].proxyHost | Hostname or IP of the Proxy | | `10.0.9.1` or `corp-proxy.domain` |\n| proxies[].proxyPort | Port of the Proxy (optional) | 3128 | |\n| proxies[].proxyUser | Proxy user name (optional) | | `testUser`|\n| proxies[].proxyPassword | Proxy password (optional) | | `testPassword` |\n| keystore.path | Keystore file path | | `classpath:keystore.jks` |\n| keystore.password | Keystore password | | `changeit` |\n| keystore.type | Keystore type (optional) | | `PKCS12` |\n| truststore.path | Truststore file path | | `classpath:truststore.jks` |\n| truststore.password | Truststore password | | `changeit` |\n| truststore.type | Truststore type (optional) | | `JKS` |\n\nExample:\n```\nhttp:\n  client:\n    proxies:\n      - hostPatterns: [\"google.de]\n        proxyHost: localhost\n        proxyPort: 3333\n        proxyUser: testUser\n        proxyPassword: testPassword\n\n    timeouts:\n      connectionTimeout: 5000\n      socketTimeout: 10000\n```\n\n## Sample Project\n\nYou can find a sample project which configures both `Feign` and `RestTemplate` to use either `OkHttp` or `Apache HttpClient` in `/httpclient-spring-boot-sample`.\n\nThe project includes the `spring-boot-maven-plugin` therefor you can simply run `mvn clean install spring:boot-run`. By default, the project uses `Apache HttpClient`, if you want to use `OkHttp`, you can use the following command:\n\n```\nSPRING_PROFILES_ACTIVE=okhttp mvn spring-boot:run\n```\n\nThe project also contains a `docker-compose.yml` file which starts several local servers to demonstrate the usecases.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveth0%2Fhttpclient-spring-boot-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeveth0%2Fhttpclient-spring-boot-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveth0%2Fhttpclient-spring-boot-starter/lists"}