Jeff
Jeff

Reputation: 2071

Naming service methods in ServiceStack

I am creating my first ServiceStack application. I think it is great but find that I have limited flexibility in the naming of methods in the Services. An example of this is I wanted to name this method GetChannels(AllChannels) but the route was not created as seen in the metadata page. I found it did work if I named it

        public object Get(AllChannels request)

Do these methods have to be named by the Verb that will call it? I am doing my routing in AppHost in the Configure().

Am I missing something? Is there a way for the route to specify the method to call?

Upvotes: 0

Views: 262

Answers (1)

mythz
mythz

Reputation: 143284

You must use either the Verb that you want to limit your Service to be called from or Any() which allows it to be called from ANY HTTP verb. Your Operation name in ServiceStack should instead be on the Request DTO, so I would change your Request DTO to be:

public object Get(GetAllChannels request)

ServiceStack promotes a message-based design where your Request DTO defines your Service contract not your methods. Please read these existing answers for learning how to design message-based Services with ServiceStack:

Upvotes: 1

Related Questions