or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/io.quarkus/quarkus-resteasy-reactive@3.15.x

docs

index.md
tile.json

tessl/maven-io-quarkus--quarkus-resteasy-reactive

tessl install tessl/maven-io-quarkus--quarkus-resteasy-reactive@3.15.0

A Jakarta REST implementation utilizing build time processing and Vert.x for high-performance REST endpoints with reactive capabilities in cloud-native environments.

quick-start.mddocs/guides/

Quick Start Guide

This guide walks you through creating your first Quarkus REST application.

Prerequisites

  • JDK 11+ installed
  • Maven 3.8+ or Gradle 7+
  • IDE with Java support

Create a New Project

Using Maven

mvn io.quarkus:quarkus-maven-plugin:3.15.7:create \
    -DprojectGroupId=com.example \
    -DprojectArtifactId=rest-quickstart \
    -DclassName="com.example.GreetingResource" \
    -Dpath="/hello"

Using Gradle

quarkus create app com.example:rest-quickstart \
    --extension=rest

Your First Endpoint

Create 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!";
    }
}

Run in Development Mode

./mvnw quarkus:dev

Or with Gradle:

./gradlew quarkusDev

Access your endpoint at: http://localhost:8080/hello

Add Path Parameters

@GET
@Path("/{name}")
@Produces(MediaType.TEXT_PLAIN)
public String greet(@RestPath String name) {
    return "Hello, " + name + "!";
}

Test: http://localhost:8080/hello/World

Add Query Parameters

@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

Return JSON

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 + "!");
}

Handle POST Requests

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();
}

Add Reactive Support

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));
}

Package and Run

Create JAR

./mvnw package
java -jar target/quarkus-app/quarkus-run.jar

Create Native Executable

./mvnw package -Dnative
./target/*-runner

Next Steps

  • Learn about Building REST APIs
  • Add Security to your endpoints
  • Explore Reactive Programming
  • Check out Common Scenarios