statgen / locuszoom

A Javascript/d3 embeddable plugin for interactively visualizing statistical genetic data from customizable sources.
https://statgen.github.io/locuszoom/
MIT License
156 stars 29 forks source link

Support POST Requests #58

Closed Frencil closed 8 years ago

Frencil commented 8 years ago

Presently LocusZoom is hard-coded to only submit GET requests to upstream APIs for data.

We have our first use case of an API that will only accept POST requests. Specifically: the ExAC API for getting gene constraint data on arbitrarily many genes can accept an array of gene IDs (e.g. all genes returned to the genes panel for the region we're looking at) but will only work with a POST request.

@MrFlick - pulling gene constraint data from the ExAC API for gene tool tips in the Broad portal's LZ implementation is on the to-do list for ADA, so this has a high priority. Please let me know what you think about the prospect of this feature and how best to get a minimum viable product for it into production LocusZoom. If you're too swamped to look at this before ADA I can potentially put something together but wouldn't presume to start without at least talking through the theory behind it with you first.

MrFlick commented 8 years ago

We are already set up to support POST requests. We would just need to customize the fetchRequest method of a new data source. The LocusZoom.createCORSPromise already supports "POST" as well as "GET". There is nothing that I see that would make this tricky.

Frencil commented 8 years ago

I was coming at it with a "reimplement as few methods as possible" approach, so it initially looked like more core work was needed. Reimplementing fetchRequest makes it all a lot simpler.

There is a small addition of making sure the CORS request includes the right Content-Type header, but that's just a small addition to createCORSPromise.

As soon as Konrad applies a cross-origin header to the endpoint I should be able to work this into a pull req that's piping gene constraints from ExAC into gene tooltips, at which point I'll submit a PR. Thanks.