A JSON-RPC 2.0 compliant framework built for Spring Boot.
RipCurl includes a Spring Boot starter, making it easy to get started by simply adding a dependency:
<dependency>
<groupId>com.callibrity.ripcurl</groupId>
<artifactId>ripcurl-spring-boot-starter</artifactId>
<version>${ripcurl.version}</version>
</dependency>By default RipCurl will listen for JSON-RPC requests on the /jsonrpc endpoint. You can change this by setting the ripcurl.endpoint property in your application.properties or application.yml file:
ripcurl.endpoint=/your-custom-endpointTo use RipCurl, you need to annotate a bean method with @JsonRpc and the bean itself with @JsonRpcService:
import com.callibrity.ripcurl.core.annotation.JsonRpc;
import org.springframework.stereotype.Component;
@Component
@JsonRpcService
public class HelloRpc {
@JsonRpc("hello")
public String sayHello(String name) {
return String.format("Hello, %s!", name);
}
}RipCurl will scan the Spring ApplicationContext for all beans annotated with the @JsonRpcService annotation and
register each of their methods annotated with @JsonRpc with the JsonRpcDispatcher.
You can then send a JSON-RPC request to the /jsonrpc endpoint with the following payload:
{
"jsonrpc": "2.0",
"id": "12345",
"method": "hello",
"params": {
"name": "RipCurl"
}
}The response will be:
{
"jsonrpc": "2.0",
"id": "12345",
"result": "Hello, RipCurl!"
}