https://github.com/codearte/resteeth
https://github.com/codearte/resteeth
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/codearte/resteeth
- Owner: Codearte
- License: apache-2.0
- Created: 2014-11-03T21:06:58.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-12-07T18:53:23.000Z (about 9 years ago)
- Last Synced: 2025-03-29T05:41:36.188Z (11 months ago)
- Language: Java
- Size: 131 KB
- Stars: 14
- Watchers: 6
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Resteeth
========
Resteeth dynamically creates rest clients based on plain java interface with Spring MVC annotations. Ready to use beans are available through standard Spring injections.
[](https://travis-ci.org/Codearte/resteeth) [](https://coveralls.io/r/Codearte/resteeth?branch=master) [](https://maven-badges.herokuapp.com/maven-central/eu.codearte.resteeth/resteeth) [](http://www.apache.org/licenses/LICENSE-2.0)
Usage
-----
1) Add dependencies
In Maven projects (pom.xml):
```xml
...
eu.codearte.resteeth
resteeth
0.2.0
...
```
In Gradle projects (build.gradle):
```groovy
repositories {
mavenCentral()
}
...
testCompile 'eu.codearte.resteeth:resteeth:0.2.0'
```
2) Enable configuration
In SpringBoot projects Resteeth will work out of the box without any configuration needed. For classical projects you have to annotate your configuration with `@EnableResteeth`
```java
@Configuration
@EnableResteeth
public class FooSpringConfig {
}
```
3) Prepare interface
```java
interface FooRestInterface {
@RequestMapping(value = "/foos/{id}", method = RequestMethod.GET)
Foo getFoo(@PathVariable("id") Integer id);
@RequestMapping(value = "/foos", method = RequestMethod.POST)
void postFoo(@RequestBody Foo user);
}
```
4) Use!
with single URL
```java
@RestClient(endpoints = {"http://api.mydomain.com"})
private FooRestInterface fooRestInterface;
Foo foo = fooRestInterface.getFoo(123);
```
or with round robin load balancing
```java
@RestClient(endpoints = {"http://api1.mydomain.com/", "http://api2.mydomain.com/"})
private FooRestInterface fooRestInterface;
Foo foo = fooRestInterface.getFoo(123);
```