Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic