How to send commands using ServiceStack?

Deadly 提交于 2019-12-06 07:31:38

This also means I have a very large DTO object which contains the data that needs to be posted to change my domain (of which a lot of the properties will be empty).

A very large DTO object with empty properties is not a performance issue since ServiceStack's text serializers (i.e. JSON/JSV) only emit data for non-null values and doesn't spend time de-serializing what's not in the payload - so it shouldn't be a concern from a performance perspective.

Other than requiring the same Request DTO to be used for each of your REST Service Verbs - there is no "ServiceStack way" on how to design your services and ServiceStack doesn't force a design-style.

If you want to prefer a more REST-ful design, you would split up your customer into manageable entities that can be modified separately, e.g to change a customers Billing address I would do something like:

PUT /customers/address/billing
{
    "Line1": "123 Street",
    "City": "Brooklyn",
    "State": "NY"
}

And have a separate REST service to manage customer addresses, e.g:

Register<CustomerAddress>("/customers/address/{AddressType}");
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!