Releasing a set of test cases for Content Negotiation

As I've written about in the past, I'm a big fan of using Server-Driven Content Negotiation for APIs for versioning, but also find it handy for being able to serve different representations of data depending on what the client supports. This is handy to be able to serve an HTML page to a browser doing a form-post, compared to JSON to an API client doing the same call.

However - and something I'm going to write about further in the future - is that doing it right is hard. Not only in how you implement the negotiation algorithm itself, but also making sure that all parts of your HTTP stack, including things like middleware, are aware of the different representations.

While writing a Go library for content negotation, I found that the Java library I wrote early last year was actually missing some cases and functionality, and needed to be fixed.

Because I want to make sure that I've got a separate record of the expected cases, as well as being able to help others building tools around content negotiation I've ended up creating a new repo, content-negotiation-test-cases.

I've validated that my Go library and my Java library are now compliant with these cases for consistency.

I'll be looking to improve test cases, and see if there are clashes with well-known and supported frameworks.

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.


Also on:

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.