Commit graph

4 commits

Author SHA1 Message Date
Jeanette Tan 894f657c48 Fix bugs from merge 2023-04-14 18:23:02 +08:00
Jeanette Tan 1570114ae1 Merge remote-tracking branch 'upstream/main' 2023-04-14 17:34:40 +08:00
Charles Korn d2d23d9849
Expose QueryData so that implementations of Codec.CanEncode() can perform a type assertion against Response.Data. (#427)
Signed-off-by: Charles Korn <charles.korn@grafana.com>
2023-02-03 05:38:40 +01:00
Charles Korn d9063441c1
Add extension point for returning different content types from API endpoints (#412)
* Add initial sketch of Codec interface.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Introduce JSON codec.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Expose Response type so that consuming applications (eg. Mimir) can implement their own Codecs.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Add sketch of what supporting different codecs could look like.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Rename fallbackCodec to defaultCodec.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Remove defaultCodec as a field on API.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Rename AddCodec() and clarify expected behaviour.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Modify TestRespond to test JsonCodec directly.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Refactor existing respond() test in preparation for content negotiation test cases.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Add tests for content negotiation.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Add missing documentation comments.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Add another test case.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Rename JsonCodec to JSONCodec.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Fix linting issue.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Fallback to JSON codec if no acceptable codec can be found for the Accept header.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

* Move custom jsoniter code into json_codec.go.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

---------

Signed-off-by: Charles Korn <charles.korn@grafana.com>
2023-02-01 09:33:50 +01:00