com.lightbend.lagom.scaladsl.api.transport
Whether this message protocol is a text based protocol.
Whether this message protocol is a text based protocol.
This is determined by whether the charset is defined.
true if this message protocol is text based.
Whether the protocol uses UTF-8.
Whether the protocol uses UTF-8.
true if the charset used by this protocol is UTF-8, false if it's some other encoding or if no charset is defined.
Convert this message protocol to a content type header, if the content type is defined.
Convert this message protocol to a content type header, if the content type is defined.
The message protocol as a content type header.
A message protocol.
This describes the negotiated protocol being used for a message. It has three elements, a content type, a charset, and a version.
The
contentType
may be registered mime type such asapplication/json
, or it could be an application specific content type, such asapplication/vnd.myservice+json
. It could also contain protocol versioning information, such asapplication/vnd.github.v3+json
. During the protocol negotiation process, the content type may be transformed, for example, if the content type contains a version, the configured HeaderFilter will be expected to extract that version out into theversion
, leaving acontentType
that will be understood by the message serializer.The
charset
applies to text messages, if the message is not in a text format, then nocharset
should be specified. This is not only used in setting of content negotiation headers, it's also used as a hint to the framework of when it can treat a message as text. For example, if the charset is set, then when a message gets sent via WebSockets, it will be sent as a text message, otherwise it will be sent as a binary message.The
version
is used to describe the version of the protocol being used. Lagom does not, out of the box, prescribe any semantics around the version, from Lagom's perspective, two message protocols with different versions are two different protocols. The version is however treated as a separate piece of information so that generic parsers, such as json/xml, can make sensible use of the content type passed to them. The version could come from a media type header, but it does not necessarily have to come from there, it could come from the URI or any other header.MessageProtocol
instances can also be used in content negotiation, an empty value means that any value is accepted.