Open route route in service handler

Using ServiceStack 3.9.2x.

Route paths are defined by decorating the DTO with the Route attribute.

Is there any way (besides reflection) to find out what a route path is in a service handler? When I say a service handler, I mean a method (Get, Put, Post, etc.) that accepts a DTO request and serves the request.

+4
source share
1 answer

You can look at the implementation of the IReturn<T>.ToUrl() extension method, which does just that, uses custom routes if it is defined otherwise it returns a pre-defined url.

Using:

 [Route("/custom/route")] public class RequestDto : IReturn<ResponseDto> { ... } var relativeUrl = new RequestDto { ... }.ToUrl("GET", "json"); 
+2
source

Source: https://habr.com/ru/post/1441848/


All Articles