I'm trying to implement a web service in apex.
I have two GET methods
GET /application
GET /application/status
1 had been already implemented in the following way. I am given the task to implement 2. Should I insert the logic in the same method below or is there a way to define a new method based on the endpoint?
@RestResource(urlMapping='/v1/application/*')
global with sharing class ApplicationAPI {
@HttpGet
global static void get() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
try {
String appID = RestUtil.getPathParam(req, 'application/');
if(appID == null) {
//get multiple apps
} else {
//get one app
}
}
catch(BadRequestException e) {
res.statusCode = e.getStatusCode();
RestUtil.setResErrorBody(res, e.getErrorCode(), e.getMessage());
}
}