set F_HTML as default if no &f={enc} or accept header is provided
resolves issue #901 plz consider that there may be regression for clients which do not send accept header and expect json to be returned
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 +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
+1 to make server.default_format a configuration directive.
+1 from me too, i'll update PR Next, what will be the default value of this param?
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...
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.
As per RFC4, this Pull Request has been closed due to there being no activity for more than 90 days.