-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from jamezp/tracing-updates
Add a new tracing resource and frontend page to execute requests and display the header data.
- Loading branch information
Showing
8 changed files
with
398 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
tracing-example/src/main/java/dev/resteasy/examples/tracing/TraceMethodResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* | ||
* Copyright 2023 Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dev.resteasy.examples.tracing; | ||
|
||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.PUT; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
/** | ||
* @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> | ||
*/ | ||
@Path("/headers") | ||
@RequestScoped | ||
@Consumes(MediaType.TEXT_PLAIN) | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public class TraceMethodResource { | ||
|
||
@GET | ||
@Path("get") | ||
public String get() { | ||
return "GET trace"; | ||
} | ||
|
||
@POST | ||
@Path("post") | ||
public String post(final String value) { | ||
return String.format("POST trace: %s", value); | ||
} | ||
|
||
@PUT | ||
@Path("put") | ||
public String put(final String value) { | ||
return String.format("PUT trace: %s", value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- | ||
~ JBoss, Home of Professional Open Source. | ||
~ | ||
~ Copyright 2023 Red Hat, Inc., and individual contributors | ||
~ as indicated by the @author tags. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee" version="4.0"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<!-- | ||
~ JBoss, Home of Professional Open Source. | ||
~ | ||
~ Copyright 2023 Red Hat, Inc., and individual contributors | ||
~ as indicated by the @author tags. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Contacts</title> | ||
<!-- CSS only --> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" | ||
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous"> | ||
<link rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.10.2/font/bootstrap-icons.min.css" | ||
integrity="sha512-YFENbnqHbCRmJt5d+9lHimyEMt8LKSNTMLSaHjvsclnZGICeY/0KYEeiHwD1Ux4Tcao0h60tdcMv+0GljvWyHg==" | ||
crossorigin="anonymous" referrerpolicy="no-referrer"/> | ||
</head> | ||
<body> | ||
|
||
<nav class="navbar navbar-dark bg-dark"> | ||
<div class="container-fluid"> | ||
<a href="#" class="navbar-brand">RESTEasy Tracing</a> | ||
</div> | ||
</nav> | ||
<div aria-live="polite" aria-atomic="true" class="position-relative"> | ||
<div id="liveAlertPlaceholder" class="toast-container top-0 end-0 p-3"></div> | ||
</div> | ||
|
||
<main class="container"> | ||
<div class="mt-3 mb-3 col-5"> | ||
<fieldset class="border rounded-3 p-3"> | ||
<legend class="float-none w-auto px-3">Choose the HTTP method to invoke:</legend> | ||
<div class="form-check"> | ||
<input class="form-check-input" type="radio" name="httpMethod" id="get" value="get" checked> | ||
<label class="form-check-label" for="get">GET</label> | ||
</div> | ||
<div class="form-check"> | ||
<input class="form-check-input" type="radio" name="httpMethod" id="post" value="post"> | ||
<label class="form-check-label" for="post">POST</label> | ||
</div> | ||
<div class="form-check"> | ||
<input class="form-check-input" type="radio" name="httpMethod" id="put" value="put"> | ||
<label class="form-check-label" for="put">PUT</label> | ||
</div> | ||
<div class="mt-4 mb-2"> | ||
<hr> | ||
<button class="btn btn-outline-primary me-2" type="button" name="submit" id="submit" | ||
data-bs-toggle="tooltip" data-bs-placement="top" | ||
data-bs-title="Submits an HTTP request"> | ||
Submit | ||
</button> | ||
<button class="btn btn-outline-danger" id="clear" name="clear" type="button" | ||
data-bs-toggle="tooltip" data-bs-placement="top" | ||
data-bs-title="Clears the data from a previous request"> | ||
Clear | ||
</button> | ||
</div> | ||
</fieldset> | ||
</div> | ||
<div class="placeholder-glow"> | ||
<div class="mb-2"> | ||
<strong>HTTP Method: </strong><span id="sentHttpMethod"></span> | ||
</div> | ||
<div class="mb-2"> | ||
<strong>Invoked: </strong><span id="url"></span> | ||
</div> | ||
<div class="mb-2"> | ||
<strong>Response: </strong><span id="response"></span> | ||
</div> | ||
</div> | ||
<table class="table table-striped mt-3"> | ||
<thead> | ||
<tr> | ||
<th class="col-md-2" scope="col">Header Name</th> | ||
<th scope="col">Header Value</th> | ||
</tr> | ||
</thead> | ||
<tbody id="output"> | ||
|
||
</tbody> | ||
</table> | ||
</main> | ||
<template id="alert"> | ||
<div class="toast align-items-center border-0 opacity-75" role="alert" aria-live="assertive" aria-atomic="true"> | ||
<div class="d-flex"> | ||
<div class="toast-body"></div> | ||
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" | ||
aria-label="Close"></button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script src="resources/main.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" | ||
crossorigin="anonymous"></script> | ||
</body> |
Oops, something went wrong.