jeudi 2 mai 2019

How should I design my restfull API to accept data via POST in different formats (JSON,CSV) for the same purpose?

I have a business requirement to develop a restfull API using Spring boot which does the following :-

a) Accept the vehicle data in csv format over a POST request from the client. b) Accept the vehicle data in JSON format over a POST request from the client.

In the above a) and b) the fields are same but just in different formats ( One is JSON and another is CSV ).

My question is how should be my design to chieve this?

1) Shall I simply go ahead by creating class A and have 2 different endpoint methods. One to accept csv and another to accept json? Or there are any better ways to deal with such scenarios?

2) What should my class structure look like?

3) Any specific design patterns that suit this requirement? Or any specific reccomendation to deal with such scenario?

Any help is highly appreciated.

Aucun commentaire:

Enregistrer un commentaire