Remove redundant api prefix path

This commit is contained in:
Andrea Cavalli 2021-11-26 18:48:17 +01:00
parent fb2427518d
commit cae18e206d
8 changed files with 23 additions and 194 deletions

View File

@ -17,7 +17,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/api/chats")
@Path("/chats")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class ChatResource {
@ -39,7 +39,7 @@ public class ChatResource {
@POST
public Uni<Response> create(Chat chat) {
return Panache.withTransaction(() -> chatRepository.persist(chat))
.onItem().transform(inserted -> Response.created(URI.create("/api/" + chat.id)).build());
.onItem().transform(inserted -> Response.created(URI.create("/chats/" + chat.id)).build());
}
@PUT

View File

@ -1,3 +1,5 @@
quarkus.http.port=8282
%prod.quarkus.datasource.db-kind=postgresql
%prod.quarkus.datasource.username=quarkus_test
%prod.quarkus.datasource.password=quarkus_test

View File

@ -23,7 +23,7 @@ public class ChatsEndpointTest {
//List all, should have all 3 usernames the database has initially:
Response response = given()
.when()
.get("/api/chats")
.get("/chats")
.then()
.statusCode(200)
.contentType("application/json")
@ -35,7 +35,7 @@ public class ChatsEndpointTest {
.when()
.body("{\"name\" : \"Telegram Official\"}")
.contentType("application/json")
.put("/api/chats/777000")
.put("/chats/777000")
.then()
.statusCode(200)
.body(
@ -45,7 +45,7 @@ public class ChatsEndpointTest {
//List all, Telegram Official should've replaced Telegram:
response = given()
.when()
.get("/api/chats")
.get("/chats")
.then()
.statusCode(200)
.contentType("application/json")
@ -56,13 +56,13 @@ public class ChatsEndpointTest {
//Delete Telegram:
given()
.when()
.delete("/api/chats/777000")
.delete("/chats/777000")
.then()
.statusCode(204);
response = given()
.when()
.get("/api/chats")
.get("/chats")
.then()
.statusCode(200)
.contentType("application/json")
@ -75,7 +75,7 @@ public class ChatsEndpointTest {
.when()
.body("{\"id\": \"777001-u\", \"name\" : \"Telegram2\"}")
.contentType("application/json")
.post("/api/chats")
.post("/chats")
.then()
.statusCode(201)
.body(emptyString());
@ -83,7 +83,7 @@ public class ChatsEndpointTest {
//List all, Pineapple should be still missing now:
response = given()
.when()
.get("/api/chats")
.get("/chats")
.then()
.statusCode(200)
.extract().response();
@ -95,7 +95,7 @@ public class ChatsEndpointTest {
public void testEntityNotFoundForDelete() {
given()
.when()
.delete("/api/chats/777123")
.delete("/chats/777123")
.then()
.statusCode(404)
.body(emptyString());
@ -107,7 +107,7 @@ public class ChatsEndpointTest {
.when()
.body("{\"id\": \"777234-u\", \"name\" : \"Juan\"}")
.contentType("application/json")
.put("/api/chats/777234")
.put("/chats/777234")
.then()
.statusCode(200);
}
@ -118,7 +118,7 @@ public class ChatsEndpointTest {
.when()
.body("{\"name\" : \"Juan\"}")
.contentType("application/json")
.put("/api/chats/777234")
.put("/chats/777234")
.then()
.statusCode(500);
}

View File

@ -6,7 +6,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/api/td")
@Path("/td")
public class TdResource {
@Inject TdService tdService;

View File

@ -14,7 +14,7 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/api/td/session/{sessionId}")
@Path("/td/session/{sessionId}")
public class TdSessionResource {
@PathParam("sessionId")

View File

@ -1,175 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>service-td - 1.0.0-SNAPSHOT</title>
<style>
h1, h2, h3, h4, h5, h6 {
margin-bottom: 0.5rem;
font-weight: 400;
line-height: 1.5;
}
h1 {
font-size: 2.5rem;
}
h2 {
font-size: 2rem
}
h3 {
font-size: 1.75rem
}
h4 {
font-size: 1.5rem
}
h5 {
font-size: 1.25rem
}
h6 {
font-size: 1rem
}
.lead {
font-weight: 300;
font-size: 2rem;
}
.banner {
font-size: 2.7rem;
margin: 0;
padding: 2rem 1rem;
background-color: #0d1c2c;
color: white;
}
body {
margin: 0;
font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}
code {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 87.5%;
color: #e83e8c;
word-break: break-word;
}
.left-column {
padding: .75rem;
max-width: 75%;
min-width: 55%;
}
.right-column {
padding: .75rem;
max-width: 25%;
}
.container {
display: flex;
width: 100%;
}
li {
margin: 0.75rem;
}
.right-section {
margin-left: 1rem;
padding-left: 0.5rem;
}
.right-section h3 {
padding-top: 0;
font-weight: 200;
}
.right-section ul {
border-left: 0.3rem solid #71aeef;
list-style-type: none;
padding-left: 0;
}
.provided-code {
border-left: 0.3rem solid #71aeef;
padding-left: 10px;
}
.provided-code h3 {
font-weight: 200;
}
</style>
</head>
<body>
<div class="banner lead">
Your new Cloud-Native application is ready!
</div>
<div class="container">
<div class="left-column">
<p class="lead"> Congratulations, you have created a new Quarkus cloud application.</p>
<h2>What is this page?</h2>
<p>This page is served by Quarkus. The source is in
<code>src/main/resources/META-INF/resources/index.html</code>.</p>
<h2>What are your next steps?</h2>
<p>If not already done, run the application in <em>dev mode</em> using: <code>./mvnw compile quarkus:dev</code>.
</p>
<ul>
<li>Your static assets are located in <code>src/main/resources/META-INF/resources</code>.</li>
<li>Configure your application in <code>src/main/resources/application.properties</code>.</li>
<li>Quarkus now ships with a <a href="/q/dev/">Dev UI</a> (available in dev mode only)</li>
<li>Play with the provided code located in <code>src/main/java</code>:</li>
</ul>
<div class="provided-code">
<h3>RESTEasy Reactive</h3>
<p>Easily start your Reactive RESTful Web Services</p>
<p><code>@Path: <a href="/api/td" class="path-link" target="_blank">/api/td</a></code></p>
<p><a href="https://quarkus.io/guides/getting-started-reactive#reactive-jax-rs-resources" class="guide-link" target="_blank">Related guide section...</a></p>
</div>
</div>
<div class="right-column">
<div class="right-section">
<h3>Application</h3>
<ul>
<li>GroupId: <code>it.volvox.service-td</code></li>
<li>ArtifactId: <code>service-td</code></li>
<li>Version: <code>1.0.0-SNAPSHOT</code></li>
<li>Quarkus Version: <code>2.4.1.Final</code></li>
</ul>
</div>
<div class="right-section">
<h3>Do you like Quarkus?</h3>
<ul>
<li>Go give it a star on <a href="https://github.com/quarkusio/quarkus">GitHub</a>.</li>
</ul>
</div>
<div class="right-section">
<h3>Selected extensions guides</h3>
<ul>
</ul>
</div>
<div class="right-section">
<h3>More reading</h3>
<ul>
<li><a href="https://quarkus.io/guides/maven-tooling.html" target="_blank">Setup your IDE</a></li>
<li><a href="https://quarkus.io/guides/getting-started.html" target="_blank">Getting started</a></li>
<li><a href="https://quarkus.io/guides/" target="_blank">All guides</a></li>
<li><a href="https://quarkus.io" target="_blank">Quarkus Web Site</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>

View File

@ -1 +1,3 @@
quarkus.http.port=8283
td.requests.timeout = 10s

View File

@ -16,7 +16,7 @@ public class TdResourceTest {
@Test
public void testEmptyList() {
given()
.when().get("/api/td/list")
.when().get("/td/list")
.then()
.statusCode(200)
.body(is(""));
@ -25,7 +25,7 @@ public class TdResourceTest {
@Test
public void testCreateSession() {
given()
.when().get("/api/td/create-session")
.when().get("/td/create-session")
.then()
.statusCode(200)
.body(not(emptyOrNullString()));
@ -34,7 +34,7 @@ public class TdResourceTest {
@Test
public void testCreateMultipleSessions() {
var sessionId1 = given()
.when().get("/api/td/create-session")
.when().get("/td/create-session")
.then()
.statusCode(200)
.body(not(emptyOrNullString()))
@ -42,7 +42,7 @@ public class TdResourceTest {
.body()
.asString();
var sessionId2 = given()
.when().get("/api/td/create-session")
.when().get("/td/create-session")
.then()
.statusCode(200)
.body(not(emptyOrNullString()))
@ -53,7 +53,7 @@ public class TdResourceTest {
var expectedBodyElems = Set.of(sessionId1, sessionId2);
var bodyElems = Set.of(given()
.when().get("/api/td/list")
.when().get("/td/list")
.then()
.statusCode(200)
.extract()