Open hongzhidao opened 4 years ago
I believe this is both a breaking change and against the REST model. Eg.: We will be returning "200 OK" for a resource not found...
I believe this is both a breaking change and against the REST model
Agree. Sorry for my carelessness.
The purpose of this change is that I want to get all the values that will be assigned to pass
.
Now, routes
, routes/{all groups}
, applications/{all apps/PHP targets}
and upstreams/{all ups
} are needed.
I found pass
can be set empty that it will return 500 for HTTP request.
Do you think if it needs to be improved (required)?
The purpose of this change is that I want to get all the values that will be assigned to pass.
Maybe a "fields query" in the API? Something like:
GET /config?fields=routes,applications,upstreams
Reply:
{
"routes": {},
"applications": null,
"upstreams": null
}
This way you're asking for a group of resources and then the API returns 200 for the object and returns null
for each one not found in the server. This also can lower the number of requests the Panel needs to send.
Do you think if it needs to be improved (required)? I'm not sure, but it seems so.
The Unit Panel/Dash is amazing, BTW! Congrats.
I think we just need to introduce support for returning default values from the API. Then "applications", "upstreams", "settings" can have defaults as {}
.
Maybe a "fields query" in the API? I think we just need to introduce support for returning default values from the API.
I prefer to keep Unit unchanged. Your suggestions have made the question clear.
Currently, I think Nginx is a good proxy to help manage Unit configuration including CORS
, jwt auth
and get passes values
. Such as.
location /passes {
js_content unit.passes; # get full configuration and filter the expected passes
}
{
"routes": {},
"applications": null,
"upstreams": null
}
Furthermore, it would be interesting that there is an example using NGINX, Unit, NJS. Thanks for your great work again :)
Hi. This question is gone. Now the process is:
client-side -- fetch data (after login) --> server-side
-- stored the config/certs data as a local JS object <--
-- just get the local JS object and show in the list pages
-- edit form or delete then submit (PUT/DELETE) -->
-- fetch data after successful operation and update the local JS object. -->
But there is a question left that I'm wondering if it is good to return full configuration together with successfully updated. After updating the configuration, it's common to get the latest data. This would be handy for JS client. Otherwise, we have to re-pull configuration data.
Hi.
This test case is important. Now, it's missed in tests/ directory. (grep
Value doesn't exist.
nothing)What about making
get value
generic. Reference to Unit configuration section.To address parts of the configuration, query the control socket over HTTP; URI path segments of your requests to the API must be names of its JSON object members or indexes of its array elements.
As I understand, the URI is used to find the config object. It represents a chain of property names. It's quite similar to access property of an object in JS. For example./config/upstreams/r1/servers
is the same asconfig['upstreams']['r1']['servers']
. Ifservers
does not exist, the get value can benull
with status 200. But config['upstreams']['r2']['servers'] still return 404, ifr2
does not exists. This only applies toobject
andarray
.+static nxt_conf_value_t nxt_conf_json_null = {
define nxt_conf_json_newline(p) \
((p)[0] = '\r', (p)[1] = '\n', (p) + 2) @@ -455,6 +459,11 @@ nxt_conf_get_path(nxt_conf_value_t value, nxt_str_t path)
@@ -465,6 +474,11 @@ nxt_conf_get_path(nxt_conf_value_t value, nxt_str_t path) }