New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a Wildcard URL Matcher #55
Conversation
Should have been modelClass.
Hi @groomsy, so in your case, the + (NSDictionary *)modelClassesByResourcePath {
return @{
@"statuses/*": [Tweet class],
@"users/*": [TwitterUser class],
@"friends/ids.json": [UserIdentifierCollection class],
@"followers/ids.json": [UserIdentifierCollection class],
@"**": [AnyOtherModel class],
};
} , right? |
@sodastsai It's been a while since I've looked at this, but if memory serves me correctly, I wanted to have a root wildcard for only one model. So any endpoint, one class. I'm not sure if your example would work (I didn't have it in mind when I opened this PR). |
okay. your original idea would be
so, all the response processed by and my comment extends above idea, the I just wanna clarify your idea. :) |
That sounds great. It covers my limited need and makes it more extensible for future implementations. 👍 |
A while ago I contributed a very simple change to make this possible without a wildcard matcher: #74 sadly, I didn't really bother to document that behaviour somewhere... |
Explicit is better than implicit. (From the Zen of Python) Thus I think it's better to point out that you want to match all URL starting with a prefix into a model class. So, the example in #94 would be refined into: ```swift override class func modelClassesByResourcePath() -> [NSObject: AnyObject] { let modelClasses: [NSObject: AnyObject] = [ "inventory/**": Item.self, ] return modelClasses } ``` (Add a `**` to match any further paths, which is a feature proposed in #55)
Merged by 9130140. @groomsy: Thanks, 👍 @stefreak: your contribution is great. But groomsy's provides a usage like this: NSDictionary *modelClassesByPath = @{
@"test/*": [OVCTestModel class],
@"test2/**": [OVCAlternativeModel class],
}; and the result would be
|
I am using a Hypermedia API adhering to the Siren specification. Every response should be the same object type. Therefore, I need an any URL wildcard for
modelClassesByResourcePath
. I have decided to use the**
identifier.