Skip to content
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

Distinguishing PUT and GET responses corresponding to the same URL #64

Closed
priyarajagopal opened this issue Nov 5, 2014 · 7 comments
Closed
Milestone

Comments

@priyarajagopal
Copy link

Hi
So I have a URL http://server/api/v1/users . This URL can be used to GET a list of user names or it can be used to PUT a list of users (the users are specified in the request body). This is quite common in RESTful services. The response to the GET and PUT requests are naturally different. How do I use Overcoat to distinguish between the GET and PUT response corresponding to the same URL ? Right now, Overcoat tries to map the PUT response to the object that I've specified in modelClassesByResourcePath for the GET query. Help please!
thanks!

@tomermobli
Copy link

hello
Can you share how you solved it?

@CeccoCQ
Copy link

CeccoCQ commented Apr 7, 2015

Hi,
have you solved?

@tomermobli
Copy link

I "solved" it by removing Overcoat... and manually parse the response with MTLJSONAdapter

@GorkaMM
Copy link

GorkaMM commented May 21, 2015

@priyarajagopal How did you finally solve this?

@sodastsai sodastsai added this to the 4.0 milestone Nov 6, 2015
@sodastsai sodastsai mentioned this issue Nov 6, 2015
11 tasks
@sodastsai
Copy link
Member

Hi guys,

though this is an issue long ago, I'd like to support this in Overcoat. (I'm new maintainer since this summer.)

I have a purpose that the URLMatcher would be configured like:

+ (NSDictionary *)modelClassesByResourcePath {
    return @{
        @"model": [OVCTestModel class],
        @"path": [OVCURLMatcherNode nodeWithClassesByHTTPRequestMethods:@{
            @"*": [SomeModel class],
            @"GET": [SomeGetModel class],
            @"PUT": [SomePutModel class],
        }],
    };
}

So all requests to URL like http://api.example.com/model would still use OVCTestModel for the response.
And the URL Matcher would use SomeGetModel for GET requests to http://api.example.com/path, SomePutModel for PUT requests, and SomeModel for other methods like POST, DELETE, and etc.

@0ldF0x
Copy link

0ldF0x commented Dec 6, 2015

What about distinguishing responses corresponding to the same URL and different query parameters.
/same/path/script.cgi, parameter: query=overview
/same/path/script.cgi, parameter: query=info

@sodastsai
Copy link
Member

@0ldF0x: sure 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants