-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Use Prefer: schema=x
as an alternative to Accept-Profile/Content-Profile
#2927
Comments
This would be great, and help clean up some Caddy Config code I've had to implement in order to abstract and "fix" this. I've seen many end users struggle with this too and make the common mistake of using the wrong header. |
If we really want to make working with multiple schemas easy, we should reconsider just doing that via the request's path, like |
That should be in its own issue but I'd be against it because:
|
That's not true. A schema is not an implementation detail as soon as you use multiple of them. Right now, you need to pass the schema in the Whether to change a header or the path in the URL if you change the schema name - does not make a difference. You need to change it anyway.
Not true, either. You just need syntax. you could do
And of course I don't agree here as well. If done right, this could actually be a step towards custom URLs. |
@wolfgangwalther I've opened a new issue for the schema path idea: #2956 I guess we can have both? I don't see why one would exclude the other. This issue is mostly about improving the current header way. |
Now that we have |
Prefer: schema=x
as an alternative to Accept-Profile/Content-Profile
Prefer is not the solution to everything. Especially not this. When you do |
That doesn't look right according to REST definition of resource. https://ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm
A schema is an implementation detail. The "concept" (say "authors") can move schemas and it'll still be the same. Having the schema on the path results in brittle URLs. This way will also give us the flexibility of doing cross-schema resource embedding if the need arises. Using paths for schemas will overcomplicate the syntax Besides that
It's the only header we can use without inventing an |
How so? I think we are just talking about two different things. Your scenario is more like versioning for example. Assume a v1 and a v2 schema. Both have a view I fully agree with you - this is not a different "thing". But this is also just a special case. Imagine two schemas, with two tables, both named
In the versioning example it might be (although the api version is hardly an implementation detail, but the fact that this is represented as a schema is). In the other example, it might very well not be an implementation detail. It might give you a much required context to actually be able to tell what "kind of items" you are dealing with. This brittle URL thing.. I really don't get it. If you use schemas in the URL - of course the URL will change when you change the schema. But the URL will also change when you rename the table or view. Why is that not an implementation detail? Where do you draw the line?
Uhm, how exactly do you put the fact that two tables in the embedding spec are in different schemas in the header? I don't get it. This seems much more complicated - because you suddenly need to draw a connection between the header and the
Well, the Accept/Content-Profile headers turned out to be... not a good idea, imho. And not only because of the different header names for GET and POST - but in general. |
From a conceptual point of view (the REST one), those
IMO at the relation level. Databases and schemas are boxes of relations. If you rename the table/view then it is a different relation thus a different concept.
Hm, I don't see why. IME besides the different headers that has been working just fine. Simple in interface, implementation and maintenance. We had another discussion about the Maybe that's the real win we have with the header approach. We're able to provide default schemas/databases for our endpoints and keep them simpler. |
I get the idea, although I don't think this would be respected in practice. Name collisions could also happen in homographs too. Since I was working on bulding the OpenAPI spec, I noticed that it's quite difficult to work with the |
OpenAPI is a valid point. So in general is harder to provide a static spec with the header approach. In that case I guess we should also ditch the |
Let's move forward with the schema in URL then. Will open a new issue for that. |
The fact that the host is transferred as a header is mostly an implementation detail of http - because nobody uses it like that. Everybody uses it as part of the URL, so there is no reason to change my proposal. |
We already have #2157. |
Problem
Changing from
Accept-Profile
toContent-Profile
depending on the HTTP request method can be confusing. See #2890 (comment) and #3231.We don't really need the flexibility of saying insert into into
schema.users
but give me the results ofanother_schema.users
on the same request. This can be achieved in theory withContent-Profile
fromAccept-Profile
.Solution
Use
Prefer: schema=x
instead and apply it to all HTTP methods.The text was updated successfully, but these errors were encountered: