We are building a machinery for ephemeral environments (“Clowder”) and one of the details is that the environment will provide different resource names, than the ones we expect in application.properties.

Not the name we requested (Picture from Pixabay)

For example, we may have the following entry in application.properties

We thus request a topic name of ingress, but the environment may provide us with a dynamic name of e.g. ingress-123. This means we need to dynamically override what is set up in applications.properties.

About MicroProfile Config

Quarkus is internally using the SmallRye implementation of Eclipse MicroProfile Config (MP-Config). MP-Config allows to add so called Configuration Sources, that allow to supply config…

In the project I am working on, we have a need to sometimes delete several items at once. The UI would send a delete request, the backend has to process it and let the UI know the outcome. So far so simple.

A bunch of trashcans
A bunch of trashcans
Trashcans. Modfied version of a picture from Pixabay

Now the tricky part begins — how do you create a good REST-API for this.

Using HTTP DELETE with a single URI

HTTP has a DELETE verb, which looks suitable for the task, as it clearly expresses the desired operation. This is described in RFC 7231. The object to be deleted would be within the URI and a 2xx return code to describe the outcome.

…and you should try it as well

I am by no way a natural baker, but rather one of those software guys that create intangible things for a living.

As so many, I have started baking my own bread during the Corona pandemic. It wasn’t because local bakeries had no more bread. I wanted to try that for a long time and this just pushed me over the edge. At first I just tried something random with mediocre success, but then got myself a good book. That book not only list a few recipes, but also contains a lot of theory, which I find helpful.

Why baking?

As I…

I have created an access log filter in my Quarkus application, that works as a Handler at the Vert.x web router layer. Now I need to pass data from my business logic at the JAX-RS layer to this access log. This post shows a possible solution.

Connected pipes by Jean-Paul Jandrain on Pixabay

In my last two articles (1, 2) I talked about how to modify HTTP-requests at the layer of the Vert.x web router, which is then transparent to the upper layers.

Similar to my previous article, we had the need to do some changes with incoming HTTP-Headers in Quarkus: users were calling the /openapi.json endpoint without requesting a specific media type, which made Quarkus return Yaml.

Bild von succo auf Pixabay

Users are so accustomed to assume that the suffix of a URL-path also determines the media type — probably because it is like this on Windows — that they expected calling /openapi.json to return data in Json format.

Looking at the Quarkus source code shows that the default media type for the OpenAPI data is Yaml. If the user wants Json, an additional HTTP Accept…

In our project we have the a REST-Api listening on BASE_PATH/v1.0/resource. Now people also want to access this via calling BASE_PATH/v1/resource. This article shows you how you can achieve this in Quarkus without additional external tooling.

Bild von Gerald Schmidtkunz auf Pixabay

Quarkus internally builds on a number of technologies of which one is Eclipse Vert.x. Vert.x Web Router (and its included Netty) provide the lower layer of the HTTP-stack, on which then other layers like the OpenAPI servlet or RestEasy for JAX-RS build upon. This means, that every incoming HTTP-request passes Vert.X before it is dispatched.

As I wrote before, I am using the MicroProfile Rest-Client to talk to another service via HTTP. Now the backend has changed a bit since I wrote the other post and now I need to pass a query parameter to tell the backend if this is a dry-run or not.

HTTP Post request with query parameter

The specification document mentions that all sort of parameters can be passed, but does not have an example for query parameters, so here we go:

Like before, verify() (1) is the method…

When one is writing software, testing is a big part of it. Unit tests of algorithms are pretty easy do achieve and run and are probably (hopefully!) an accepted standard these days.

Units waiting to be tested

Things are getting more interesting when external dependencies come into play. This is often called integration testing. But in reality what one wants to test is not really the integration into the target environment, but rather that basic assumptions on how to interact with other systems are met. Very often mock objects come into play, that for example abstract away database access to provide result objects. Unfortunately this…

If you are creating REST-APIs in Java, you have probably already heard of JAX-RS. While JAX-RS may be implemented on top of Servlets, there is no requirement to do so. This also means that you may not be able to use Servlet-specific things like ServletFilters.

But don’t fear — JAX-RS provides a nice alternative and I’ll show you how you can easily implement an authentication filter that way. The interface is javax.ws.rs.container.ContainerRequestFilter, where we need to implement the filter() method, which we’ll do below. The other job we have to do is to decide where it will be applied in…

The Eclipse MicroProfile Rest-Client is a pretty cool piece of software. I think I even mentioned that before 😀. And one of the cool features is that you don’t have to deal with the low level http handling.

But sometimes you want to actually deal with the nitty gritty of http — notably dealing with different status codes that convey a semantic. The default handling is that for every code ≥ 400, a WebApplicationException is thrown, which just tells you that the call did not succeed, but does not differentiate further.

Custom Exception Mappers to the rescue

Luckily one does not need to resort back to…

Heiko W. Rupp

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store