• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

spring http request mapping single uri with different request parameters to different method

 
Greenhorn
Posts: 16
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
My question is I need to implement rest api to search Students bases on its attributes
below are my urls.

http<<host:port>/my system/vo1/students/search?firstname=ABC&responseType=summary
http<<host:port>/my system/vo1/students/search?age=ABC&responseType=summary
http<<host:port>/my system/vo1/students/search?id=ABC& responseType =summary
http<<host:port>/my system/vo1/students/search?mobile=ABC& responseType =summary
http<<host:port>/my system/vo1/students/search?lastname=ABC& responseType =summary
http<<host:port>/my system/vo1/students/search?education=ABC& responseType=summary
http<<host:port>/my system/vo1/students/search?working=ABC& responseType =summary
http<<host:port>/my system/vo1/students/search? responseType =summary


responseType can be summary,hierarchy or can more types will be added in feature.

So i have single URI "/my system/vo1/students/search?" with different parameters
and user will send max two optional parameters and min is one is mandatory that is responseType

in spring we can map single uri with different request parameters to different method as shown below



and so on .. we can write 9 different methods for this .

one more way is to do it create only one method.



In second approach we can write separate validator to validate the input request.

I have below Questions
1. which approach is best (considering best design principals and practices)
2. why it is best approach
3. what is best object oriented design for such problem

 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yashwantrao ,
I will go for the second one .Because it is more generic , coding is small and easily to understand .
 
Yashwantrao Raut
Greenhorn
Posts: 16
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Majumder,

I thought same way but i wanted to validate it is correct or not.
looking more answer for this question.
 
reply
    Bookmark Topic Watch Topic
  • New Topic