anacrolix / confluence

Torrent client as a HTTP service
Mozilla Public License 2.0
236 stars 32 forks source link

Return JSON from /info based on Accept header #19

Closed boramalper closed 4 years ago

boramalper commented 4 years ago

Implements https://github.com/anacrolix/confluence/issues/18


$ curl -H 'accept: application/json' "http://127.0.0.1:8080/info?ih=b8aefdbc4d06b2f69829f8a091a01d60e3a7886c"
{"Announce":"","AnnounceList":[],"Nodes":[],"CreationDate":1586250574,"Comment":"dynamic metainfo from client","CreatedBy":"go.torrent","Encoding":"","UrlList":[]}```
boramalper commented 4 years ago

I am not sure if you are notified of the changes I have made so commenting for heads up. =)

anacrolix commented 4 years ago

Ok I'm still not sure about the field names, but everything else looks good.

boramalper commented 4 years ago

If we separate them by space (in contrast to using camelCase), the fields cannot be accessed using dot operator object.fileldName in JS, which is the canonical way. Instead, you’d have to use object["field name"].

Not a big thing so I don’t want to turn this into bike-shedding, but let me know which one you prefer and I’ll update accordingly.