@RemoteMethod

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

- {@link oajrc.remote.RemoteMethod}
  - {@link oajrc.remote.RemoteMethod#method method}
  - {@link oajrc.remote.RemoteMethod#path path}
  - {@link oajrc.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:

@RemoteResource 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`:

@RemoteResource 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 oajrc.remote.RemoteMethod#returns() returns} annotation with a value of {@link oajrc.remote.RemoteReturn#STATUS STATUS}:

##### Example:

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