ServiceStack:"Matching = ..." 规则的解释
ServiceStack: Explaination of the "Matching = ..." rules
我需要解释 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; }
}
但我得到了:
: 'Unknown Matches Rule '**/{string}' in Route
'/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
我想我可以使用匹配规则来区分它们。但是,我不确定我必须遵守哪些规则,或者为什么一个有效而另一个无效。
请参阅有关注册的文档 Custom Matching Rules,如果您不使用内置规则,则需要在 Config.RequestRules
中注册实施。
我需要解释 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; }
}
但我得到了:
: 'Unknown Matches Rule '**/{string}' in Route '/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
我想我可以使用匹配规则来区分它们。但是,我不确定我必须遵守哪些规则,或者为什么一个有效而另一个无效。
请参阅有关注册的文档 Custom Matching Rules,如果您不使用内置规则,则需要在 Config.RequestRules
中注册实施。