{title:'@RemoteOp', updated:'8.2.0', updated:'9.0.0'}

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

Specialized sub-annotations are provided for common HTTP methods:

@RemoteOp(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} | @RemoteGet("/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 | @RemoteOp | Pet getPet(...); | }

In such cases, the @RemoteOp 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
@RemoteOp(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.RemoteOp#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. | @RemotePost(returns=STATUS) | int pets(...); | }

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 POJO Categories.