@RemoteMethod

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

- {@link oaj.http.remote.RemoteMethod}
  - {@link oaj.http.remote.RemoteMethod#method method}
  - {@link oaj.http.remote.RemoteMethod#path path}
  - {@link oaj.http.remote.RemoteMethod#returns returns}

##### @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:

- void - Don't parse any response.
  Note that the method will still throw a runtime exception if an error HTTP status is returned.
- Any {@doc PojoCategories parsable} POJO - The body of the response will be converted to the POJO using the parser defined on the RestClient based on the Content-Type of the response.
- Any {@link oaj.http.annotation.Response @Response}-annotated type. (described later)
- HttpResponse - Returns the raw HttpResponse returned by the inner HttpClient.
- {@link java.io.Reader} - Returns access to the raw reader of the response.
- {@link java.io.InputStream} - Returns access to the raw input stream of the response.

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}.