Home Spring Rest API - spurious/not requested parameters strategy
Reply: 0

Spring Rest API - spurious/not requested parameters strategy

user930
1#
user930 Published in July 16, 2018, 6:26 am

According to this discussion - "RESTful API - Correct behavior when spurious/not requested parameters are passed in the request", we shouldn't ignore not requested parameters but how we can process this situation on all endpoint?

For example for this endpoint:

@RequestMapping(value = "/transactions/",
        method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public RestResultSupport getCommandsById(@PathVariable("id") String id) throws IOException {
    validateId(id);
    ....
    return result;
}

We'll get the same result for 2 different requests:

curl localhost:8080/?id=1200

and

curl localhost:8080/?id=1200&unknown=incorrect

If we imagine that we should process this situation on 20 endpoints, how can we simplify our code? Does Spring provide some tools for that?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.312043 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO