-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(adapter) Create an adpater to use RestTemplate (#7)
* feat(adapter) Create an adpater to use RestTemplate --------- Co-authored-by: Arnaud THOREL<arnaud.thorel@ouest-france.fr>
- Loading branch information
1 parent
680a69c
commit d3e0f47
Showing
101 changed files
with
1,345 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
/.idea | ||
*.iml | ||
.gitlab-ci.yml | ||
|
||
**/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<div align="center" style="text-align:center;padding-top: 15px"> | ||
<img alt="logo-ouest-france" src="https://sipaui.sipaof.fr/downloads/logotheque/ouest-france-couleur.svg" height="100"/> | ||
<h1 style="margin: 0;padding: 0">PostgRest-RestTemplate-Adapter</h1> | ||
</div> | ||
<div align="center" style="text-align: center"> | ||
|
||
[![Build Status][maven-build-image]][maven-build-url] | ||
[![Coverage][coverage-image]][coverage-url] | ||
[![Quality Gate Status][sonar-image]][sonar-url] | ||
[![Download][maven-central-image]][maven-central-url] | ||
|
||
</div> | ||
|
||
**QueryDSL-PostgRest-RestTemplate-Adapter** is a httpclient adapter of [QueryDSL-Postgrest](https://github.com/Ouest-France/querydsl-postgrest). | ||
|
||
**PostgREST** is an open source project that provides a fully RESTful API from any existing PostgreSQL database | ||
|
||
## Getting Started | ||
|
||
### Maven integration | ||
|
||
Add the following dependency to your Maven project: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>fr.ouestfrance.querydsl</groupId> | ||
<artifactId>querydsl-postgrest-resttemplate-adapter</artifactId> | ||
<version>${querydsl-postgrest.version}</version> | ||
</dependency> | ||
``` | ||
|
||
### Gradle integration | ||
|
||
Add the following dependency to your gradle project: | ||
|
||
```groovy | ||
implementation 'fr.ouestfrance.querydsl:querydsl-postgrest-resttemplate-adapter:${querydsl-postgrest.version}' | ||
``` | ||
|
||
### Configure PostgrestClient | ||
QueryDsl postgrest need implementation of PostgrestClient with a specific HttpAdapter. | ||
|
||
It's really easy to create your own HttpClientAdapter (RestTemplate, OkHttpClient, HttpConnexion, ...) by | ||
implementing `PostgrestClient` interface. | ||
|
||
You can also specify authenticators, interceptors (retry, transform) and every configuration (timeout, default headers, | ||
cookies, ...) you need to deploy. | ||
|
||
#### Configuration example | ||
|
||
```java | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import fr.ouestfrance.querydsl.postgrest.PostgrestClient; | ||
import fr.ouestfrance.querydsl.postgrest.PostgrestRestTemplate; | ||
import org.apache.hc.client5.http.impl.classic.HttpClients; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; | ||
import org.springframework.web.client.RestTemplate; | ||
import org.springframework.web.util.DefaultUriBuilderFactory; | ||
|
||
@Configuration | ||
public class PostgrestConfiguration { | ||
|
||
@Bean | ||
public PostgrestClient podstgrestClient() { | ||
String serviceUrl = "http://localhost:9000"; | ||
RestTemplate restTemplate = new RestTemplate(); | ||
restTemplate.setUriTemplateHandler(new DefaultUriBuilderFactory(serviceUrl)); | ||
restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(HttpClients.createDefault())); | ||
return PostgrestRestTemplate.of(webclient); | ||
} | ||
} | ||
``` | ||
|
||
## Need Help ? | ||
|
||
If you need help with the library please start a new thread QA / Issue on github | ||
|
||
## Contributing | ||
|
||
If you want to request a feature or report a bug, please create a GitHub Issue | ||
|
||
If you want to make a contribution to the project, please create a PR | ||
|
||
## License | ||
|
||
The QueryDSL is licensed under [MIT License](https://opensource.org/license/mit/) | ||
|
||
[maven-build-image]: https://github.com/Ouest-France/querydsl-postgrest/actions/workflows/build.yml/badge.svg | ||
|
||
[maven-build-url]: https://github.com/Ouest-France/querydsl-postgrest/actions/workflows/build.yml | ||
|
||
[coverage-image]: https://codecov.io/gh/ouest-france/querydsl-postgrest/graph/badge.svg | ||
|
||
[coverage-url]: https://codecov.io/gh/ouest-france/querydsl-postgrest | ||
|
||
[maven-central-image]: https://maven-badges.herokuapp.com/maven-central/fr.ouestfrance.querydsl/querydsl-postgrest/badge.svg | ||
|
||
[maven-central-url]: https://mvnrepository.com/artifact/fr.ouestfrance.querydsl/querydsl-postgrest | ||
|
||
[sonar-image]: https://sonarcloud.io/api/project_badges/measure?project=Ouest-France_querydsl-postgrest&metric=alert_status | ||
|
||
[sonar-url]: https://sonarcloud.io/summary/new_code?id=Ouest-France_querydsl-postgrest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>fr.ouestfrance.querydsl</groupId> | ||
<artifactId>querydsl-postgrest-bom</artifactId> | ||
<relativePath>../pom.xml</relativePath> | ||
<version>1.2.3-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>querydsl-postgrest-resttemplate-adapter</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>fr.ouestfrance.querydsl</groupId> | ||
<artifactId>querydsl-postgrest</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-web</artifactId> | ||
<version>6.1.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>3.14.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.15.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents.client5</groupId> | ||
<artifactId>httpclient5</artifactId> | ||
<version>5.3</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>3.2.1</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<phase>deploy</phase> | ||
<goals> | ||
<goal>jar-no-fork</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>3.4.1</version> | ||
<executions> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Oops, something went wrong.