Created
September 13, 2014 14:12
-
-
Save tzmfreedom/8166aa68ec1e12cf4f94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestResource(urlMapping='/MyRestContextExample/*') | |
global with sharing class AnonymousHandler { | |
@HttpGet | |
global static Account doGet() { | |
RestRequest req = RestContext.request; | |
RestResponse res = RestContext.response; | |
res.addHeader('Access-Control-Allow-Origin', '*'); | |
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1); | |
Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE Id = :accountId]; | |
return result; | |
} | |
@HttpPost | |
global static Boolean doPost() { | |
RestRequest req = RestContext.request; | |
RestResponse res = RestContext.response; | |
res.addHeader('Access-Control-Allow-Origin', '*'); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment