kalisio / krawler

A minimalist (geospatial) ETL
https://kalisio.github.io/krawler/
MIT License
54 stars 13 forks source link

Allow to define content response for a status code #255

Closed claustres closed 1 year ago

claustres commented 1 year ago

Following fix for https://github.com/kalisio/krawler/issues/254, we should provide a way to define a default response body related to a HTTP code if required. Indeed, some codes (like 204) do not provide any content at all so that all hooks should deal with the different type of content based on some predicate, which is not convenient. For instance, for a JSON API any readJson hook, and further processing hooks, will have to deal with undefined content for a 204 response.

It would be better to define a default content for responses without a body so that hooks will not have to deal with the different type of content. For instance, in the JSON API use case, this content will be similar to an empty content returned with status 200.