Skip to content

Rename json -> data and remove JSON-specific content-type setting #30

@milancurcic

Description

@milancurcic

#27 introduced a new API to the request function which now accepts an optional json argument. This is generally fine except that on our Friday call we agreed that rather than json we'd call this argument data as it can accept any kind of data. The only thing JSON-specific here is that this sets Content-Type to application/json, but the user can set that via headers already. My main issue with this approach is that we use the name of the argument to determine and communicate the Content-Type, so if we were to be consistent, this approach would warrant adding arguments such as binary, text, etc.. Let's not do that.

On our Friday call, we agreed that we'd call this argument data, and what you have currently proposed as data in #24, we would call form.

Continuing from our call, and what should have been noted in #24, let's proceed with the following API:

function new_request(url, method, header, data) result(response)
    integer, intent(in), optional :: method
    character(len=*), intent(in) :: url
    character(len=*), intent(in), optional :: data
    type(header_type), intent(in), optional :: header(:)

Let's tackle this first before any other changes to the API. For the time being, the user will be responsible for setting the appropriate Content-Type, whether that's application/json or otherwise.

We can then discuss any possible API for setting type data.

Recall that while we always want to consult the APIs of popular libraries like Python requests, we don't always want to copy their APIs if we don't find them optimal.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions