Would it be worth factoring this out into a public type that can be used within Play more generally? Not suggesting this as part of this PR, but if there's utility then perhaps a new issue...?