-
-
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
[WIP] Allow specifying root function #1302
Conversation
Come to think of it, we can enforce content negotiation is respected. Right now we check the content types available and respond with an error before we hit the db. For RPC we could relax this restriction and addtionally check that the requested media type Would have to check matching rules for things like |
(leaving aside that the changes in this pr until now are useful, setting the response headers) in what way will this PR make things better (after the changes you want to implement for the root path) compared to a user/me just creating a normal RPC, then writing a 5 line nginx config and pointing the root location to the new RPC, where by the way I can control the headers however I want, I can set caching headers (and cache the actual output), etc, etc ... and all that without any new logic and additional config parameters? While here you are talking about not trivial things like looking at request/response headers and rolling back transactions |
We already do something similar here, check the
It'll be only one additional config option and pgrst can also control the headers. Not every user is proficient in nginx(they could use caddy, apache, etc) and we can remove the need for the proxy plus the 5 lines of config that the user needs to add so it can start customizing it's root function. This process should be straightforward since here we are talking about contributors helping us solve our openapi issues(possibly gaining openapiv3 and other specs). |
That code is there because it's the only place where that can be done, it's core to what postgrest does, openapi is not
nobody is, it's a case of reading the manual and writing a few lines.
I thought we established long time ago that there needs to be a proxy in every setup
It's not about who does the job, it's about if this needs to be done at all. So far what i understand is that the answer to my main question (how is it better then doing it in proxy) is "the users don't have to write the 5 lines" (which by the way can also be documented the same as the function if that is a big problem) |
Resource metadata is core to REST, openapi happens to be the spec we have supported for years already so it should remain and prevent a major breaking change. Also other specs can be added as I mentioned.
Remove the need for the proxy for the root function.
It's better because you don't need the proxy plus x lines of code config(simplicity). |
a thing that is not implemented/used in 99% of rest apis in the real world can not be "core" to rest
both methods (new config vs proxy location) are the exact same thing in relation to breaking changes (a user needs to create a function in the db and edit a config file). Another point is that no one is really using/caring about this more then slapping swagger-ui on top and saying "look how cool" since the output never was 100 complete/correct.
in other words, the proxy is still there (because it's needed in all setups), it's just not used for the root location so there is no reduction of operational complexity here.
as said above, the proxy is there (for a whole lot of reasons/features postgrest does nto implement), so you DO still needed it. A couple of haskell functions as oposed to a few nginx config lines is the oposite of simplicity. |
I might be wrong a bit about |
So far I don't see a strong reason for not implementing this. Bottom line is that we have many pending issues regarding openapi and the pr presents a solution. So, I'll proceed. Regarding content negotiation, I'll make the pr simpler and not enforce anything for now. Just add the ability to do |
Closing in favor of #1317. |
As discussed in #790 (comment). With this function we could solve all the current OpenAPI issues.
This is a work in progress.
To do this first we need to be able to override the
Content-Type
(in case user wants to specifyapplication/openapiv3+json
or other spec). Previously we discussed this in #986 (comment).For now content negotiation is kind of broken on RPC, since client can specify
Accept: x
and server can respond withContent-Type: y
. Not sure if we should enforce a way to make this consistent or leave the responsibility to the user.