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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final dev.relism.flash.ext.jackson.Codec
     

    Methods inherited from class dev.relism.flash.ext.jackson.JacksonHandler

    body

    Methods inherited from class dev.relism.flash.models.BodyHandler

    bodyType, bodyTypeOf, handle, handle

    Methods inherited from class dev.relism.flash.models.RequestHandler

    bind, find, onInit, optional, require

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JsonHandler

      public JsonHandler()
  • Method Details

    • codec

      protected final dev.relism.flash.ext.jackson.Codec codec()
      Specified by:
      codec in class dev.relism.flash.ext.jackson.JacksonHandler<B>