A REST endpoint gives a service an HTTP interface. In Quarkus, a Jakarta RESTful Web Services resource class can expose a path and handle a request method. The generated example handles GET /hello and returns plain text. section 2.2.2
Listing 2.4 GreetingResource class: generated sample JAX-RS endpoint
package org.acme;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
@Path("/hello") #1
public class GreetingResource {
@GET #2
@Produces(MediaType.TEXT_PLAIN) #3
public String hello() {
return "Hello from Quarkus REST"; #4
}
}
The resource class uses @Path to set /hello, @GET to handle the request, and @Produces to declare a plain-text response. section 2.2.2
Test the HTTP behavior rather than only calling the Java method: a Quarkus test sends GET /hello and checks for status 200 and the expected body. An integration test can reuse those checks against the packaged application. section 2.2.2
Listing 2.5 Quarkus test example with REST Assured
package org.acme;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;
@QuarkusTest
public class GreetingResourceTest {
@Test
public void testHelloEndpoint() {
given()
.when().get("/hello")
.then()
.statusCode(200) #1
.body(is("Hello from Quarkus REST")); #2
}
}
The REST Assured test shows the request and the two response assertions. section 2.2.2
For a reservation service, the endpoint has a more practical job: return cars available between supplied dates and accept a reservation for a car and date range. The quarkus-rest-jackson extension supplies REST functionality with Jackson support for JSON requests and responses. The quarkus-smallrye-openapi extension generates API documentation and a UI for trying endpoints. When running multiple services, configure a different HTTP port to avoid conflicts. section 4.2
A REST endpoint is also a CDI bean without an added CDI annotation. In Dev UI, the Beans page lists it with the default @Singleton scope and offers a link to its source code. section 3.3.1

























