ContentNegotiationService

Content negotiation service for DID resolution.

Supports multiple content types for DID documents to ensure interoperability with different clients and use cases.

Supported Content Types:

  • application/did (default) - DID 1.1 / DID Resolution 1.0 media type

  • application/did+ld+json - JSON-LD format with full context (legacy, DID Core 1.0)

  • application/did+json - Plain JSON format without JSON-LD processing (legacy, DID Core 1.0)

  • application/did+cbor - CBOR format for compact representation

  • application/json - Fallback JSON format

Example Usage:

val negotiationService = DefaultContentNegotiationService()

// Negotiate content type from Accept header
val contentType = negotiationService.negotiateContentType("application/did+cbor")

// Serialize document
val bytes = negotiationService.serializeDocument(document, contentType)

Inheritors

Functions

Link copied to clipboard
abstract suspend fun deserializeDocument(data: ByteArray, contentType: String): DidDocument

Deserialize document from content type.

Link copied to clipboard
abstract suspend fun negotiateContentType(acceptHeader: String?, defaultType: String = DidMediaTypes.DID): String

Negotiate content type from Accept header.

Link copied to clipboard
abstract suspend fun serializeDocument(document: DidDocument, contentType: String): ByteArray

Serialize document to requested content type.