Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RestResource(urlMapping='/mypath/*')
- global without sharing class MyRest {
- @HttpGet
- global static void get() {
- RestResponse res = RestContext.response;
- if (res == null) {
- res = new RestResponse();
- RestContext.response = res;
- }
- try {
- res.responseBody = Blob.valueOf(JSON.serialize(doGet()));
- res.statusCode = 200;
- } catch (EndUserMessageException e) {
- res.responseBody = Blob.valueOf(e.getMessage());
- res.statusCode = 400;
- } catch (Exception e) {
- res.responseBody = Blob.valueOf(
- String.valueOf(e) + 'nn' + e.getStackTraceString()
- );
- res.statusCode = 500;
- }
- }
- private static Object doGet() {
- ...
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement