Activitypub Server: Content negotiation inevitable?

When having e.g. an id of a post at hand (take, how would one go about to send a like?

It needs the inbox url - how to get that?

First send a GET to the id – which yields html (targeting the lesser tech savvy still preferring html over json).

How would one do that on a with static posts on a webserver like lighttpd, althttpd or thttpd?

You will need to send a json GET, obtain the attributedTo actor and then create a like with the ‘to’ field to that actor.

1 Like

thanks, that’s how I do but wanted ideas how to distinguish html and json connoisseurs.

I just found lighttpd can do such

  $REQUEST_HEADER["Accept"] == "application/activity+json" {
    index-file.names = ( "index.json" )

and return json to those who want it easily. Hope the other webservers may likewise.

We typically switch formats in the controller, but that doesn’t align with some architectures. Do whatever works.

Incidentally please do not trigger on ‘application/activity+json’ alone. ActivityPub uses ‘application/ld+json;profile=“\”’ (without the backslash - which I needed to prevent a link preview) and using this is a MUST if I recall.

If you’re not supporting multiple protocols the ActivityPub definition is the gold standard.

We match on a few variations because new projects get it wrong about 50% of the time - and our own protocol is also based on ActivityStreams and that specification actually does use ‘application/activity+json’.


so maybe more appropriate may be

$REQUEST_HEADER["Accept"] =~ "[^/]+/.*json.*" {
    index-file.names = ( "index.json" )

If this works for your project - sure.