package marshalling
- Alphabetic
- Public
- Protected
Type Members
- abstract class AbstractMessageBodyReader[T] extends MessageBodyReader[T]
Transforms an HTTP Message into an object.
Transforms an HTTP Message into an object. Usable from Java.
- Note
Scala users please use the MessageBodyReader trait.
- abstract class AbstractMessageBodyWriter[T] extends MessageBodyWriter[T]
Transforms an object into an HTTP Response.
Transforms an object into an HTTP Response. Usable from Java.
- Note
This allows Java users to not have to implement the base
,#write(Message, T)
unless necessary as a defaulted implementation exists in the trait but needs to be accessible to Java users as an abstract class.Scala users please use the MessageBodyWriter trait.
- trait DefaultMessageBodyReader extends AnyRef
Marker trait denoting a class that can act as a default com.twitter.finatra.http.marshalling.MessageBodyReader for the HTTP server.
Marker trait denoting a class that can act as a default com.twitter.finatra.http.marshalling.MessageBodyReader for the HTTP server.
This default is invoked when the
com.twitter.finatra.http.internal.CallbackConverter
cannot find a suitable com.twitter.finatra.http.marshalling.MessageBodyReader to convert the incoming Finagle request into the route callback input type. E.g., given a defined route in a Controller:get("/") { request: T => ... }
The
com.twitter.finatra.http.internal.CallbackConverter
attempts to locate a com.twitter.finatra.http.marshalling.MessageBodyManager which can parse a Finagle request into the input typeT
. If one is not found, this default is invoked.The framework binds com.twitter.finatra.http.internal.marshalling.DefaultMessageBodyReaderImpl as an overridable implementation via the com.twitter.finatra.http.modules.MessageBodyModule.
To override this implementation, provide a customized com.twitter.inject.TwitterModule by overriding com.twitter.finatra.http.HttpServer.messageBodyModule, e.g.,
class MyServer extends HttpServer { ... override val messageBodyModule = MyCustomMessageBodyModule }
The framework default com.twitter.finatra.http.marshalling.MessageBodyReader will attempt to convert the incoming request body using the server's configured com.twitter.util.jackson.ScalaObjectMapper and is the basis for the framework's JSON Integration with Routing.
The com.twitter.finatra.http.marshalling.DefaultMessageBodyReader trait differs from the com.twitter.finatra.http.marshalling.MessageBodyReader trait in that the default is not parameterized to a specific type but instead defines a generic
parse[T]
function which can generate a typeT
from a given request.A com.twitter.finatra.http.marshalling.MessageBodyReader is expected to only ever generate a single type
T
from itsparse[T]
implementation.- Note
this class is explicitly NOT an extension of com.twitter.finatra.http.marshalling.MessageBodyReader because it is bound to the object graph and needs to support injectable value lookup by type passed into the parse method.
- See also
com.twitter.finatra.http.internal.marshalling.DefaultMessageBodyReaderImpl
https://twitter.github.io/finatra/user-guide/json/routing.html#requests
- trait DefaultMessageBodyWriter extends MessageBodyWriter[Any]
A marker trait denoting a class that can act as a default com.twitter.finatra.http.marshalling.MessageBodyWriter for the HTTP server.
A marker trait denoting a class that can act as a default com.twitter.finatra.http.marshalling.MessageBodyWriter for the HTTP server.
This default is invoked by either the
com.twitter.finatra.http.internal.CallbackConverter
(by invoking the com.twitter.finatra.http.response.ResponseBuilder) or com.twitter.finatra.http.response.ResponseBuilder#write directly to return a suitable response for a given return type.The framework binds com.twitter.finatra.http.internal.marshalling.DefaultMessageBodyWriterImpl as an overridable implementation via the com.twitter.finatra.http.modules.MessageBodyModule. To override this implementation, provide a customized com.twitter.inject.TwitterModule by overriding com.twitter.finatra.http.HttpServer.messageBodyModule, e.g.,
class MyServer extends HttpServer { ... override val messageBodyModule = MyCustomMessageBodyModule }
The framework default will attempt to convert the outgoing type
T
to a JSON response using the server's configured com.twitter.util.jackson.ScalaObjectMapper.The com.twitter.finatra.http.marshalling.DefaultMessageBodyWriter trait differs from the com.twitter.finatra.http.marshalling.MessageBodyWriter trait in that the default is not parameterized to a specific type but instead defines a generic
write[T]
function which can generate a response from a given typeT
.- Note
this class is an extension of the com.twitter.finatra.http.marshalling.MessageBodyWriter trait parameterized to the
Any
type.- See also
com.twitter.finatra.http.internal.marshalling.DefaultMessageBodyWriterImpl
https://twitter.github.io/finatra/user-guide/json/routing.html#responses
- trait MessageBodyComponent extends AnyRef
Marker trait for MessageBodyReaders and MessageBodyWriters
- class MessageBodyManager extends AnyRef
Manages registration of message body components.
Manages registration of message body components. I.e., components that specify how to parse an incoming Finagle HTTP request body into a model object ("message body reader") and how to render a given type as a response ("message body writer").
A default implementation for both a reader and a writer is necessary in order to specify the behavior to invoke when a reader or writer is not found for a requested type
T
. The framework binds two default implementations: DefaultMessageBodyReader and DefaultMessageBodyWriter via the com.twitter.finatra.http.modules.MessageBodyModule.These defaults are overridable by providing a customized
MessageBodyModule
in your com.twitter.finatra.http.HttpServer by overriding the com.twitter.finatra.http.HttpServer.MessageBodyModule.When the MessageBodyManager is obtained from the injector (which is configured with the framework com.twitter.finatra.http.modules.MessageBodyModule) the framework default implementations for the reader and writer will be provided accordingly (along with the configured server injector).
- trait MessageBodyReader[T] extends MessageBodyComponent
Transforms an HTTP Message into an object.
Transforms an HTTP Message into an object.
- Note
Java users should prefer the AbstractMessageBodyReader abstract class.
- trait MessageBodyWriter[T] extends MessageBodyComponent
Transforms an object into an HTTP Response.
Transforms an object into an HTTP Response.
- Note
Java users should prefer the AbstractMessageBodyWriter abstract class.
- case class MustacheBodyComponent(data: Any, templateName: String, contentType: String) extends MessageBodyComponent with Product with Serializable
- class MustacheMessageBodyWriter extends MessageBodyWriter[Any]
- Annotations
- @Singleton()
- abstract class WriterResponse extends AnyRef
Value Members
- object MessageBodyFlags
- object MessageBodyManager
- object MessageBodyReader
- object WriterResponse
- object mapper
- object response