sealed trait MessageProtocol extends AnyRef
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 as application/json
, or it could be an application
specific content type, such as application/vnd.myservice+json
. It could also contain protocol versioning
information, such as application/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 the version
, leaving a contentType
that
will be understood by the message serializer.
The charset
applies to text messages, if the message is not in a text format, then no charset
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.
- Source
- MessageProtocol.scala
- Alphabetic
- By Inheritance
- MessageProtocol
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Abstract Value Members
- abstract val charset: Option[String]
- abstract val contentType: Option[String]
- abstract val version: Option[String]
- abstract def withCharset(charset: String): MessageProtocol
- abstract def withContentType(contentType: String): MessageProtocol
- abstract def withVersion(version: String): MessageProtocol
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
+(other: String): String
- Implicit
- This member is added by an implicit conversion from MessageProtocol to any2stringadd[MessageProtocol] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
-
def
->[B](y: B): (MessageProtocol, B)
- Implicit
- This member is added by an implicit conversion from MessageProtocol to ArrowAssoc[MessageProtocol] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
ensuring(cond: (MessageProtocol) ⇒ Boolean, msg: ⇒ Any): MessageProtocol
- Implicit
- This member is added by an implicit conversion from MessageProtocol to Ensuring[MessageProtocol] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: (MessageProtocol) ⇒ Boolean): MessageProtocol
- Implicit
- This member is added by an implicit conversion from MessageProtocol to Ensuring[MessageProtocol] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean, msg: ⇒ Any): MessageProtocol
- Implicit
- This member is added by an implicit conversion from MessageProtocol to Ensuring[MessageProtocol] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean): MessageProtocol
- Implicit
- This member is added by an implicit conversion from MessageProtocol to Ensuring[MessageProtocol] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from MessageProtocol to StringFormat[MessageProtocol] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isText: Boolean
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.
- returns
true if this message protocol is text based.
-
def
isUtf8: Boolean
Whether the protocol uses UTF-8.
Whether the protocol uses UTF-8.
- returns
true if the charset used by this protocol is UTF-8, false if it's some other encoding or if no charset is defined.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toContentTypeHeader: Option[String]
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.
- returns
The message protocol as a content type header.
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
→[B](y: B): (MessageProtocol, B)
- Implicit
- This member is added by an implicit conversion from MessageProtocol to ArrowAssoc[MessageProtocol] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc