All Projects → Codearte → resteeth

Codearte / resteeth

Licence: Apache-2.0 License
No description, website, or topics provided.

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects

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.

Build Status Coverage Status Maven Central Apache 2

Usage

  1. Add dependencies

In Maven projects (pom.xml):

<pom>
    ...
    <dependencies>
        <dependency>
            <groupId>eu.codearte.resteeth</groupId>
            <artifactId>resteeth</artifactId>
            <version>0.2.0</version>
        </dependency>
    </dependencies>
    ...
</pom>

In Gradle projects (build.gradle):

repositories {
   mavenCentral()
}
...
testCompile 'eu.codearte.resteeth:resteeth:0.2.0'
  1. 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

@Configuration
@EnableResteeth
public class FooSpringConfig {

}
  1. Prepare interface
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);

}
  1. Use!

with single URL

@RestClient(endpoints = {"http://api.mydomain.com"})
private FooRestInterface fooRestInterface;

Foo foo = fooRestInterface.getFoo(123);

or with round robin load balancing

@RestClient(endpoints = {"http://api1.mydomain.com/", "http://api2.mydomain.com/"})
private FooRestInterface fooRestInterface;

Foo foo = fooRestInterface.getFoo(123);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].