The “Quarkus RESTful Temperature Converter” is a simple demonstrative application that exposes a RESTful web service for temperature conversion developed with Quarkus (the “Supersonic Subatomic” Java Framework).
The application currently supports 6 temperature units: Celsius – Fahrenheit – Kelvin – Rankine – Réaumur – Rømer
This project is exclusively developed by Andrea Binello (“andbin”).
This project is released under the MIT License, a very permissive free software license. See the full text of the license:
You can also see external resources like here or here.
The project requires at least:
- a JDK 11 or later version
- a very recent version of Maven (e.g. Maven 3.6.3 is ok)
Then you can build and run the application with:
mvn compile quarkus:dev
or using the Maven “wrapper” with:
mvnw compile quarkus:dev
The REST API is very simple and consists of only 4 endpoints. You can try and test the API using curl or Postman or any other similar tool.
→ GET http://host:port/temperatures
curl http://localhost:8080/temperatures
Output (JSON):
[ {
"code" : "celsius",
"name" : "Celsius",
"symbol" : "°C"
}, {
"code" : "fahrenheit",
"name" : "Fahrenheit",
"symbol" : "°F"
},
......other units, truncated for brevity
]
→ GET http://host:port/temperatures/{unit}
curl http://localhost:8080/temperatures/celsius
Output (JSON):
{
"code" : "celsius",
"name" : "Celsius",
"symbols" : [ "°C" ],
"waterFreezingPoint" : 0.0,
"waterBoilingPoint" : 100.0,
"namedAfter" : "Anders Celsius",
"establishmentYear" : 1742
}
curl http://localhost:8080/temperatures/rankine
Output (JSON):
{
"code" : "rankine",
"name" : "Rankine",
"symbols" : [ "°R", "°Ra" ],
"waterFreezingPoint" : 491.67,
"waterBoilingPoint" : 671.67,
"namedAfter" : "William John Macquorn Rankine",
"establishmentYear" : 1859
}
→ GET http://host:port/temperatures/{fromUnit}/{toUnit}/{value}?d={fractionalDigits}
Query param d
is the number of fractional digits used for rounding the result. It can be a value from 0 to 7 and is optional (default value: 4).
curl http://localhost:8080/temperatures/celsius/fahrenheit/32.7
Output (JSON):
{
"from" : {
"value" : 32.7,
"name" : "Celsius",
"symbol" : "°C"
},
"to" : {
"value" : 90.86,
"name" : "Fahrenheit",
"symbol" : "°F"
}
}
→ GET http://host:port/temperatures/{fromUnit}/others/{value}?d={fractionalDigits}
Query param d
is the number of fractional digits used for rounding the result. It can be a value from 0 to 7 and is optional (default value: 4).
curl http://localhost:8080/temperatures/celsius/others/32.7
Output (JSON):
{
"from" : {
"value" : 32.7,
"name" : "Celsius",
"symbol" : "°C"
},
"to" : [ {
"value" : 90.86,
"name" : "Fahrenheit",
"symbol" : "°F"
}, {
"value" : 305.85,
"name" : "Kelvin",
"symbol" : "K"
},
......other units, truncated for brevity
]
}
In path templates you can use the full code/name (lower case) of a temperature unit or any possible abbreviation (prefix):
http://localhost:8080/temperatures/celsius
http://localhost:8080/temperatures/celsiu
http://localhost:8080/temperatures/celsi
http://localhost:8080/temperatures/cels
http://localhost:8080/temperatures/cel
etc... are all OK. The important thing is that there is no ambiguity between multiple temperature units!