Skip to content

danijeldragicevic/compress-decompress-jsons-rest-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compress/Decompress JSON files REST service

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.

Technology

  • RAML 1.0
  • Mule 4.4.0EE

To run application:

Checkout from this repository and import into Anypoint Studio 7.X.X.

Exposed endpoints:

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

Examples

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.

Screenshot 2023-02-16 at 11 51 07

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.

Screenshot 2023-02-16 at 12 02 18

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.

Licence

License

About

Service who is able to compress or decompress JSON files.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages