こんな感じでクラスの@RestResourceアノテーションでルーティングをして、メソッドに@HttpGetとか@HttpPostとかアノテーションをつければ、http methodに応じて呼ばれるメソッドが変わる。メソッド名は何でもいいみたい。
しかし、これだと1クラスで1つのURLしか定義できず、同じく1クラスでget、post、put、delete用の4つのAPIしか公開できない。何かいい方法ないんだろうか。ルーティングはメソッドごとにできればいいのに。
あとAPIとして公開するためには、クラスがglobalでないとダメ。
@RestResource(urlMapping='/Hogehoge/v1/*')
global with sharing class RestApiHogehoge {
@HttpPut
global static updateHogehoge() {
RestApiHogehogeResponse response = new RestApiHogehogeResponse();
respnse.string1 = "test1";
respnse.string2 = "test2";
return response;
}
global class RestApiHogehogeResponce {
global String string1;
global String string2;
}
}