简体   繁体   中英

ServiceStack Grouping of Requests Together

Now I may have my thinking of this all wrong seeing as though I'm relatively new to ServiceStack, however, if I was to have three API requests all part of the same request, for example:

  1. /Broadcast/Add
  2. /Broadcast/Get
  3. /Broadcast/Delete

Each of these are going to have completely different request parameters (POST) so I would create three DTOs each with the necessary parameters eg:

public class AddBroadcastMessage
{
    public string Content { get; set; }
    public DateTime StartTime { get; set; }
    public DateTime EndTime { get; set; }
    public int IParent { get; set; }
    public string MessageType { get; set; }
}

public class GetBroadcastMessages 
{
    public DateTime StartTime { get; set; }
    public DateTime EndTime { get; set; }
    public int IParent { get; set; }
} 

public class DeleteBroadcastMessage
{
    public int Id { get; set; }
}

Then, I would have a Service for each of these with a OnGet override method because of the different parameters, eventually as more APIs were added, the logic check of the service would become difficult to follow for developers who were later added to the team.

In the metadata page these would be separate requests (due to the different DTOs), is there anyway that I can group these three DTOs on the metadata page?

I have tried using the ApiAttribute eg [Api("Broadcast")]

and I have also tried setting the first segment of the route to the same text.

If it is of any importance, we register our routes in the Configure method

Thanks

OnGet is a very old version of ServiceStack that has long since been deprecated. Please refer to ServiceStack docs below for guidance on designing Services with ServiceStack:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM