Form Object -> Request Object
Replace Form objects with Request objects that parse HTTP request URL/body and are returned inside Success/Failure (i.e., Result monads)
Service objects should always return ApiResult objects, wrapped in Result monads
Presentation Object -> Representer / HATEOS
Representers are now the key part of the new presentation layer of your API
Every domain entity and value will likely need a representer
Consider which methods of your domain objects require representation as Json
Employ HATEOS by creating relevant links in representers
Create an HttpResponse representer that picks the HTTP status code from
ApiResult objects
Failure: use HttpResponse representer to create status code and body of
response
Success: use HttpResponse representer to create status code of response
use domain object representers to create Json body of response
寫測試
Ensure service objects are tested
Ensure routes are tested using rack-test
API設計
Form Object -> Request Object Replace Form objects with Request objects that parse HTTP request URL/body and are returned inside Success/Failure (i.e., Result monads) Service objects should always return ApiResult objects, wrapped in Result monads
Presentation Object -> Representer / HATEOS Representers are now the key part of the new presentation layer of your API Every domain entity and value will likely need a representer Consider which methods of your domain objects require representation as Json Employ HATEOS by creating relevant links in representers
Create an HttpResponse representer that picks the HTTP status code from ApiResult objects Failure: use HttpResponse representer to create status code and body of response Success: use HttpResponse representer to create status code of response use domain object representers to create Json body of response
寫測試 Ensure service objects are tested Ensure routes are tested using rack-test
分工