docs
reference
tessl install tessl/maven-io-quarkus--quarkus-resteasy-reactive@3.15.0A Jakarta REST implementation utilizing build time processing and Vert.x for high-performance REST endpoints with reactive capabilities in cloud-native environments.
This guide walks you through creating your first Quarkus REST application.
mvn io.quarkus:quarkus-maven-plugin:3.15.7:create \
-DprojectGroupId=com.example \
-DprojectArtifactId=rest-quickstart \
-DclassName="com.example.GreetingResource" \
-Dpath="/hello"quarkus create app com.example:rest-quickstart \
--extension=restCreate a simple REST endpoint:
package com.example;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
@Path("/hello")
public class GreetingResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Hello from Quarkus REST!";
}
}./mvnw quarkus:devOr with Gradle:
./gradlew quarkusDevAccess your endpoint at: http://localhost:8080/hello
@GET
@Path("/{name}")
@Produces(MediaType.TEXT_PLAIN)
public String greet(@RestPath String name) {
return "Hello, " + name + "!";
}Test: http://localhost:8080/hello/World
@GET
@Path("/greeting")
@Produces(MediaType.TEXT_PLAIN)
public String customGreeting(
@RestQuery String name,
@RestQuery @DefaultValue("Hello") String greeting
) {
return greeting + ", " + name + "!";
}Test: http://localhost:8080/hello/greeting?name=Alice&greeting=Hi
public class Greeting {
public String message;
public String timestamp;
public Greeting(String message) {
this.message = message;
this.timestamp = Instant.now().toString();
}
}
@GET
@Path("/json")
@Produces(MediaType.APPLICATION_JSON)
public Greeting getJson(@RestQuery String name) {
return new Greeting("Hello, " + name + "!");
}public class Message {
public String content;
}
@POST
@Path("/messages")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createMessage(Message message) {
// Process message
return Response.status(201)
.entity(message)
.build();
}import io.smallrye.mutiny.Uni;
@GET
@Path("/async")
public Uni<String> asyncGreeting(@RestQuery String name) {
return Uni.createFrom().item(() -> "Hello, " + name + "!")
.onItem().delayIt().by(Duration.ofMillis(100));
}./mvnw package
java -jar target/quarkus-app/quarkus-run.jar./mvnw package -Dnative
./target/*-runner