Closed kdesjard closed 5 months ago
As far as I understand, the already existing public_server_url
has the same goal as the url
configuration you're adding. This configuration option should probably be returned by bbox_core::endpoints::abs_req_baseurl
when defined. Or are there other places you're planning to return a user defined public url?
Sorry, I can't believe I missed that. How would I get the public_server_url in datasource/postgis.rs or inventory.rs ?
public_server_url
is currently only returned in the OpenAPI Yaml or JSON at /openapi
. It should be used in all places where the public URL is returned. As I said, using it in bbox_core::endpoints::abs_req_baseurl would cover more endpoints, but there are probable others to implement as well.
Looking at the spec and other implementations, the href's in the "links" are absolute.
For example, in postgis.rs's setup_collection, the CoreCollection's ApiLink href:
href: format!("/collections/{id}/items"),
should really be:
href: format!("{public_server_url}/collections/{id}/items"),
There isn't an HttpRequest to pass into abs_req_baseurl.
Thanks, Kris
Can you point me to a spec, where you saw this requirement? I've run some OGC conformance tests and they didn't complain! I'm against using absolute URLs in metatdata for the same service since WMS 1.0.
Absolute is not a requirement, but I think is more ergonomic for an end-user.
https://docs.ogc.org/is/19-072/19-072.html
"NOTE The href value is not restricted to absolute links. Relative links are also allowed."
However, pygeoapi does it:
https://demo.pygeoapi.io/stable/collections/obs?f=json
and mapserver:
https://demo.mapserver.org/cgi-bin/mapserv/localdemo/ogcapi/collections?f=json
Anyway, maybe it could be a config parameter to use absolute url's?
For a human user of the JSON API it's probably more ergonmic, indeed. So you can just click on a link. I'm for using bbox_core::endpoints::abs_req_baseurl
wherever possible, since this gives you the correct URL in most cases without configuration. But as you say, setup_collection
is a place, where there is no request information yet. Maybe inserting a base URL when delivering collection metadata is not that hard?
For your consideration:
Add a url config parameter to set the fully qualified external url used by the webapp. This allows the server_addr to listen to one address while the url may be used at a load balancer/proxy level.
The url parameter becomes a global static URL via once_cell that can be used to generate fully qualified urls in the various services throughout the app.
I will have subsequent patches to make the feature URL's fully qualified and more OGC compliant.