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=“\https://www.w3.org/ns/activitystreams”’ (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’.