@RemoteMethod
The {@link oajrc.remote.RemoteMethod @RemoteMethod} annotation is applied to methods
of
The HTTP method and path are mapped to a Java method using the method
and path
annotations.
The Java method name can be anything.
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
:
In such cases, the
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)
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 |
The return type of the Java methods of can be any of the following:
RestClient
based on the Content-Type
of the response.
HttpResponse
- Returns the raw HttpResponse
returned by the inner HttpClient
.
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}:
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}.