A REST wankery question
Consider a simple photo storage service as an API. Users can only interact with the API if they’ve got an account. Let’s say authorization happens over HTTP Basic.
Given that, would you use URIs like /photos
and /photos/{id}
(as a
photo list and photo detail resource, respectively)? What’s weird about
those URIs is that my /photos
is a different list of photos than
your /photos
– in other words, the resource represented depends on
the information in the Authorization
header.
It seems like URIs like /people/{my-uid}/photos
and
/people/{my-uid}/photos/{photo-id}
are more “pure.” But now that’s
weird because only one single user ever has access to a given URI (e.g
only user #7 gets to access the entire space under /people/7
). And
the information in the URI is redundant with the information in the
Authorization
header.
I guess the question comes down to whether HTTP headers “should” be allowed to determine the resource returned.
So which would you use? Why?