REST Endpoints
- Annotate resource classes with
@Pathand use@GET,@POST,@PUT,@DELETEfor HTTP methods. - Return
StringorResponsefor plain text. Addrest-jacksonorrest-jsonbfor JSON serialization. - Use
@RestParamfor parameter binding, or omit the annotation entirely — RESTEasy Reactive infers parameter types from the method signature. - For async endpoints, return
Uni<T>orMulti<T>from Mutiny. - For custom status codes, return
RestResponse<T>(type-safe) orResponse. @GETendpoints typically do NOT need@Transactional.- Inject services with
@Inject. Keep business logic out of resource classes.
Filters and Exception Mapping
- Use
@ServerRequestFilterand@ServerResponseFilteron methods for simple filters. - Use
@ServerExceptionMapperon methods in resource classes to map exceptions to responses. - Both approaches are simpler than implementing
ContainerRequestFilterorExceptionMapper<T>.
Testing
- Use
@QuarkusTestwith REST Assured for endpoint testing. - Use
@TestHTTPEndpoint(MyResource.class)to avoid hardcoding paths. - Test both success and error paths.
- Test classes and methods can be package-private (JUnit 5 does not require public).
Common Pitfalls
- Resource classes default to
@Singletonin RESTEasy Reactive. Use@RequestScopedif you need per-request state. @Pathon class +@Pathon methods combine (e.g./api+/items=/api/items).- REST Reactive (this extension) is NOT compatible with RESTEasy Classic — do not mix them.