Class JsonHandler<B>
java.lang.Object
dev.relism.flash.models.RequestHandler
dev.relism.flash.models.BodyHandler<B>
dev.relism.flash.ext.jackson.JacksonHandler<B>
dev.relism.flash.ext.jackson.json.JsonHandler<B>
public abstract class JsonHandler<B>
extends dev.relism.flash.ext.jackson.JacksonHandler<B>
A handler that takes a JSON body of one type.
@POST("/users")
public final class CreateUser extends JsonHandler<NewUser> {
@Inject private UserService users;
@Override protected Object handle(Request req, Response res, NewUser body) {
return users.create(body);
}
}
The body is read off the request stream, verified against the constraints its type declares, and handed over. A malformed body is a 400, a body that breaks a constraint is a 422, and neither ever reaches the handler. The published OpenAPI document describes the same type.
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class dev.relism.flash.ext.jackson.JacksonHandler
bodyMethods inherited from class dev.relism.flash.models.BodyHandler
bodyType, bodyTypeOf, handle, handleMethods inherited from class dev.relism.flash.models.RequestHandler
bind, find, onInit, optional, require
-
Constructor Details
-
JsonHandler
public JsonHandler()
-
-
Method Details
-
codec
protected final dev.relism.flash.ext.jackson.Codec codec()- Specified by:
codecin classdev.relism.flash.ext.jackson.JacksonHandler<B>
-