Mule4 example app. Able to receive and produce compressed files.
Service is able to:
- receive plain JSON data, compress it to ZIP format and store in local file;
- receive zipped JSON data, decompress it and store in local file.
- RAML 1.0
- Mule 4.4.0EE
Checkout from this repository and import into Anypoint Studio 7.X.X.
By default, service will run on http://localhost:8081
Following endpoints will be exposed:
Methods | Urls | Action |
---|---|---|
GET | /console | Gives access to the generated documentation for the API |
POST | /api/compress | Compress payload and store to the local directory |
POST | /api/decompress | Decompress payload and store to the local dir |
Example 1: GET http://localhost:8081/console/
Run in browser or REST client tool (e.g. Insomnia, Postman...) to open generated documentation for the API.
It gives opportunity to interact with the API by setting the expected Contetn-Type and payload.
Example 2: POST http://localhost:8081/api/compress
Setting of Content-Type is mandatory. In this case we have to set it to the "application/json" type.
Request body:
[
{
"firstName": "Jane",
"lastName": "Doe"
},
{
"firstName": "Judy",
"lastName": "Doe"
},
{
"firstName": "John",
"lastName": "Doe"
},
{
"firstName": "James",
"lastName": "Doe"
}
]
Response: 200 OK.
Response body:
{
"message": "Successfully processed"
}
As result, compressed file with the payload content will be created on the "src/main/resources/output" path.
Example 2: POST http://localhost:8081/api/decompress
Setting of Content-Type is mandatory. In this case we have to set it to the "application/zip" type.
To place compressed file in the payload it is most convenient to use some REST client tool.
Response: 200 OK.
Response body:
{
"message": "Successfully processed"
}
As result, decompressed file with the payload content will be created on the "src/main/resources/output" path.