我需要解释Matching =“ ...”规则中的字符串应该看谁。
我在docs.servicestack.com上仅看到几个示例:
[Route("/users/{Id}", Matches = "**/{int}")]
[Route("/{UserId}/profile", Matches = @"{int}/**")]
[Route("/feed", Matches = "IsAuthenticated")]
还有一些。
我尝试过:
[Route("/myservice/bookings/{SearchString}", Matches = "**/{string}", Verbs = "GET")]
public class SearchAddress : IReturn<SearchAddressResponse>
{
public string SearchString { get; set; }
}
但是我得到了:
:路由中的“未知匹配规则” ** / {string}” '/ myservice / bookings / {SearchString}''
我可能会补充说,此规则可以很好地工作:
[Route(/myservice/bookings/{BookingId}", Matches = "**/{int}", Verbs = "GET")]
public class GetBooking: IReturn<GetBookingResponse>
{
[ApiMember(IsRequired = true)]
public uint BookingId { get; set; }
}
我有
/myservice/bookings/{SearchString} // a string to search for bookings
和
/myservice/bookings/{BookingId} // an Int for a specific booking
,我认为我可以使用“匹配”规则来区分它们。但是,我不确定我必须遵循哪些规则,或者为什么一个规则有效而另一个规则却无效。