@RemoteMethod

The {@link oaj.http.remote.RemoteMethod @RemoteMethod} annotation is applied to methods of @Remote-annotated interfaces to identify REST endpoints.

@RemoteMethod(method/path)

The HTTP method and path are mapped to a Java method using the method and path annotations.

Example:

@Remote public interface PetStore { // GET /pets/{petId} @RemoteMethod(method="GET", path="/pets/{petId}") Pet getPet(@Path("petId") int id); }

The Java method name can be anything.

Inferred method/path

In such cases, method and path annotations are optional if you follow certain naming conventions on your method that identify the method and path.

For example, the getPet method below defaults to GET /pet:

@Remote public interface PetStore { // GET /pet @RemoteMethod Pet getPet(...); }

In such cases, the @RemoteMethod annotation is optional.

Method names matching the following pattern are assumed to be implying the HTTP method name:

(get|put|post|delete|options|head|connect|trace|patch).*

do(?i)(get|put|post|delete|options|head|connect|trace|patch)

Examples:
Java method name Inferred HTTP method Inferred HTTP path
getPet() GET /pet
get() GET /
postPet() POST /pet
fooPet() [default] /fooPet
doGet() GET /
doGET() GET /
doFoo() [default] /doFoo
@RemoteMethod(returns)

The return type of the Java methods of can be any of the following:

If you're only interested in the HTTP status code of the response, you can use the {@link oaj.http.remote.RemoteMethod#returns() returns} annotation with a value of {@link oaj.http.remote.RemoteReturn#STATUS STATUS}:

Example:

@Remote public interface PetStore { // POST /pets // Returns HTTP status code. @RemoteMethod(returns=STATUS) int postPets(...); }

If your RestClient does not have a parser associated with it, then the value is converted directly from a String using the rules defined in {@doc PojosConveribleToStrings}.