A REST/JSON web API in Java 8+ that accepts an array of numeric inputs and performs the following:
-
Finds the highest 3 numbers
-
Computes the square root of the sum of squares of the 3 highest numeric inputs. The following is an example input:
Run Application using eclipse
-
clone or download the project
-
open project eclipse IDE
-
convert to maven project
-
run MathUtilsApiApplication.java
Run Application using Maven
- ./mvnw package && java -jar target/MathUtilsApi-1.0.0.jar
http://localhost:8080/v1/calculate
http://localhost:8080/swagger-ui.html
curl -X POST \
http://localhost:8080/v1/calculate \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"data": [5,4,6,1]
}
'
curl -X POST \
http://localhost:8080/v1/calculate \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"data": [5,4,6,1,8]
}
'
curl -X POST \
http://localhost:8080/v1/calculate \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
}
'
curl -X POST \
http://localhost:8080/v1/calculate \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"data": []
}'
curl -X POST \
http://localhost:8080/v1/calculate \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"data": [1,2]
}'