etalab / transpo-rt

Simple API for public transport realtime data
https://tr.transport.data.gouv.fr/
GNU Affero General Public License v3.0
20 stars 9 forks source link

Implement HEAD queries #113

Open thbar opened 3 years ago

thbar commented 3 years ago

When playing with data, it is very common to use curl -I (aka --head) to fetch only the headers.

Currently doing so on this app will return a 404, which can be a bit confusing too to newcomers.

I am unsure how costly it would be to implement that at the moment given my current knowledge of Actix.

Maybe there is a nice trick in Actix to ensure most GET queries can also be transformed to HEAD more or less automatically.

Less urgent than other enhancements, but still nice to have!

thbar commented 3 years ago

BTW, one trick to still show headers is to override the method after passing -I like this:

$ curl -I -X GET https://tr.transport.data.gouv.fr
HTTP/1.1 200 OK
content-length: 17808
content-type: application/json
date: Mon, 18 Jan 2021 10:49:47 GMT
Sozu-Id: 3c232174-837f-4e93-be84-3ee81aff10e4

(source: https://stackoverflow.com/a/38679650)