Package dev.relism.flash.models
Class BodyHandler<B>
java.lang.Object
dev.relism.flash.models.RequestHandler
dev.relism.flash.models.BodyHandler<B>
- Type Parameters:
B- the body type
A handler whose request carries a body of a known type.
The type is the class's own type argument, so it is written once, in the signature:
@POST("/users")
public final class CreateUser extends JsonHandler<NewUser> {
@Override protected Object handle(Request req, Response res, NewUser body) {
return users.create(body);
}
}
Reading the body is the format's job: a subclass such as JsonHandler implements
body(dev.relism.flash.models.Request) and declares its media type with
@Consumes. Documentation tools read both off the
class, which is what lets a request body be described without saying its type a second time.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract BReads the body in the format this handler speaks.bodyType()This handler's body type, for the reader inbody(dev.relism.flash.models.Request).static Class<?> bodyTypeOf(Class<?> handlerClass) The body type a handler class declares, ornullwhen it leaves it open.final ObjectHandles an incoming request.protected abstract Object
-
Constructor Details
-
BodyHandler
public BodyHandler()
-
-
Method Details
-
bodyTypeOf
The body type a handler class declares, ornullwhen it leaves it open.Resolved through the whole chain, so an intermediate base class that passes its own type argument along answers with the type its subclass fixed.
-
bodyType
This handler's body type, for the reader inbody(dev.relism.flash.models.Request). Null only on a handler left generic. -
body
Reads the body in the format this handler speaks.- Throws:
Exception
-
handle
- Throws:
Exception
-
handle
Description copied from class:RequestHandlerHandles an incoming request. The return value determines the response body: return aResponseto replace the whole response, any other non-null value to set it as the body, ornullto leave the response as-is.- Specified by:
handlein classRequestHandler- Throws:
Exception
-