pygeoapi icon indicating copy to clipboard operation
pygeoapi copied to clipboard

set F_HTML as default if no &f={enc} or accept header is provided

Open pvgenuchten opened this issue 3 years ago • 6 comments

resolves issue #901 plz consider that there may be regression for clients which do not send accept header and expect json to be returned

pvgenuchten avatar May 15 '22 10:05 pvgenuchten

Hi @pvgenuchten, I see the need for such a fix (although I still find it odd that Google, Yandex, etc. apparently do not send an Accept header), but I am not sure if simply returning F_HTML instead of None is the right solution. Note that this will affect APIRequest.is_valid() too.

Perhaps we should make this configurable in the YAML, i.e. let the admin decide what the default_format is if nothing was specified from one of these values (and by default we can set that to html of course). For example, something like:

server:
    bind:
        host: 0.0.0.0
        port: 5000
    url: http://localhost:5000
    mimetype: application/json; charset=UTF-8
    encoding: utf-8
    default_format: html
    ...

If you don't wish to make this configurable, another option could be to introduce a requested_format property in the APIRequest class, that may still return None. This way, API routes can still decide which format they need: the "interpreted" format or the actual requested one.

@tomkralidis / @francbartoli What do you think?

GeoSander avatar May 16 '22 09:05 GeoSander

@GeoSander +1 to make the default format configurable. For example, in a couple of production instances, which are not internet-facing, having the HTML format doesn't make any sense at all

francbartoli avatar May 16 '22 09:05 francbartoli

+1 to make server.default_format a configuration directive.

tomkralidis avatar May 16 '22 11:05 tomkralidis

+1 from me too, i'll update PR Next, what will be the default value of this param?

pvgenuchten avatar May 20 '22 13:05 pvgenuchten

Updated the PR, the config already has a server.mimetype param, which i now use as default, if not provided it defaults to html.

@GeoSander some advice on MIMETYPE[], if it is an array i can set it at api.init, and use it in apirequest, if it is a basic string var this does not work...

pvgenuchten avatar May 20 '22 18:05 pvgenuchten

As per RFC4, this Pull Request has been inactive for 90 days. In order to manage maintenance burden, it will be automatically closed in 7 days.

github-actions[bot] avatar Mar 10 '24 21:03 github-actions[bot]

As per RFC4, this Pull Request has been closed due to there being no activity for more than 90 days.

github-actions[bot] avatar Mar 31 '24 03:03 github-actions[bot]