gbv / cocoda-sdk

SDK for Cocoda and coli-conc services
https://gbv.github.io/cocoda-sdk/
MIT License
5 stars 1 forks source link

/status API endpoint overrides configured endpoint #21

Closed nichtich closed 3 years ago

nichtich commented 4 years ago

Given a configuration

{
    "provider": "ConceptApi",
    "api": "http://example.org/",
    "schemes": "http://example.com/voc"
}

The schemes endpoint will be ignored but overridden by what is returned by /status endpoint.

I think this and #20 could be solved by filling this._api only after initialization with values from /status in _setup instead of _prepare.

stefandesu commented 4 years ago

I see your point. There are several different issues here though:

What do you think?

nichtich commented 4 years ago

A solved my use case for this issue by putting jskos-server instance behind a proxy so I could change endpoint base URIs. We could document the current behavior:

stefandesu commented 4 years ago

That's a good solution. Would you be opposed to using null instead of undefined for explicitly disabling an endpoint? It's much easier to check: status.type === null vs status.hasOwnProperty("type") && status.type === undefined.

nichtich commented 4 years ago

Nevermind null!

stefandesu commented 3 years ago

So, it is now implemented this way:

Also, if the request to /status returns explicitly with a 404 error (i.e. it's not a network issue or some other server issue), we'll define that status endpoint as null.

Together with https://github.com/gbv/jskos-server/issues/119, this should now work as expected.

stefandesu commented 3 years ago

We could change one more thing @nichtich, if you want: If the request to /status was successful, even endpoints that are not explicitly set to null will not be assumed to be there, considering that the server should know best which endpoints exist. What do you think?

nichtich commented 3 years ago

This makes a lot of sense

stefandesu commented 3 years ago

I forgot to implement this because the issue was closed, oops. Will ship a 1.0.1 tomorrow.

stefandesu commented 3 years ago