Chapter 3. Developing RESTful Services

Quarkus integrates with RESTEasy, a JAX-RS implementation to define REST APIs. In this chapter, you’ll learn how to develop RESTful web services in Quarkus. We’ll cover the following topics:

  • How to use JAX-RS for creating CRUD services

  • How to enable CORS for requesting resources from other domains

  • How to implement reactive routes

  • How to implement filters to manipulate requests and responses

3.1 Creating a Simple REST API Endpoint


You want to create a REST API endpoint with CRUD operations.


Use the JAX-RS GreetingResource resource generated previously and fill it with JAX-RS annotations.

JAX-RS is the default framework used in Quarkus to define REST endpoints. All of the JAX-RS annotations are already correctly on your classpath. You will want to use the HTTP verb annotations (@GET, @POST, @PUT, @DELETE) to declare the HTTP verb(s) that the endpoint methods will listen to. Of course, you will need the @Path annotation to define the URI relative to the rest of the application for your endpoint.


package org.acme.quickstart;

@Path("/hello") 1
public class GreetingResource {
    public String hello() {
        return "hello" ...

Get Quarkus Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.