This application is an example REST API that REST services can be modeled after. It includes several basic features of a modern production level REST service.
This branch features the most basic structure and framework for an average production level REST service
These basic features include:
- Basic package structure
- Spring Security - Basic Authentication
- Swagger
- Spring Boot Actuator
- Unit Test examples
- Spring Profiles
- Enabled Configuration Properties
- Custom Exception Handler for error handling
- Logback
- JaCoCo Test Coverage Plugin
Please clone this repo to your run the code to see how it works. Play around with it! Experiment with all the above noted features to get a deeper understanding of how they work so that you can confidently implement them into your own code.
http://localhost:8080/swagger-ui.html
get status of application
get git information of application
header name | value | description | required |
---|---|---|---|
Content-Type | application/json | request object type | true |
Authorization | - | Basic Authentication | true |
curl -i -X POST \
http://localhost:8080/test \
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Authorization: Basic dGVzdDp0ZXN0MTAw' \
-H 'Connection: keep-alive' \
-H 'Content-Length: 27' \
-H 'Content-Type: application/json' \
-H 'Cookie: JSESSIONID=639473E390EE936177B1C7BEDEFFC42F' \
-H 'Host: localhost:8080' \
-H 'User-Agent: PostmanRuntime/7.16.3' \
-d '{
"msisdn": "1234567890"
}'
HTTP/1.1 200
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Sun, 15 Sep 2019 08:11:18 GMT
{"status":"Success"}
{
"msisdn": "1234567890"
}
{
"baseError": {
"code": "string",
"explanation": "string",
"reason": "string"
},
"body": {
"status": "string"
}
}
{
"baseError": {
"code": "string",
"explanation": "string",
"reason": "string"
},
"body": {}
}
header name | value | description | required |
---|---|---|---|
Content-Type | application/json | request object type | true |
Authorization | - | Basic Authentication | false |
curl -i -X POST \
http://localhost:8080/testWithoutAuth \
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Connection: keep-alive' \
-H 'Content-Length: 27' \
-H 'Content-Type: application/json' \
-H 'Cookie: JSESSIONID=639473E390EE936177B1C7BEDEFFC42F' \
-H 'Host: localhost:8080' \
-H 'User-Agent: PostmanRuntime/7.16.3' \
-d '{
"msisdn": "1234567890"
}'
HTTP/1.1 200
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Sun, 15 Sep 2019 09:42:21 GMT
{ "baseError": { "code": "string", "explanation": "string", "reason": "string" }, "body": { "status": "string" } }
{
"msisdn": "1234567890"
}
{
"baseError": {
"code": "string",
"explanation": "string",
"reason": "string"
},
"body": {
"status": "string"
}
}
{
"baseError": {
"code": "string",
"explanation": "string",
"reason": "string"
},
"body": {}
}