Package com.jetdrone.vertx.yoke

Examples of com.jetdrone.vertx.yoke.Middleware


    @Test
    public void testEngine() {
        Yoke yoke = new Yoke(this);
        yoke.engine("html", new ThymeleafEngine("views"));
        yoke.use(new Middleware() {
            @Override
            public void handle(YokeRequest request, Handler<Object> next) {
                request.put("home.welcome", "Hi there!");
                request.response().render("template.html");
            }
View Full Code Here


    }

    @Test
    public void testNormalizedPath4() {
        final Yoke yoke = new Yoke(this);
        yoke.use(new Middleware() {
            @Override
            public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
                assertNull(request.normalizedPath());
                testComplete();
            }
View Full Code Here

    }

    @Test
    public void testNormalizedPath5() {
        final Yoke yoke = new Yoke(this);
        yoke.use(new Middleware() {
            @Override
            public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
                assertNull(request.normalizedPath());
                testComplete();
            }
View Full Code Here

            router.patch(Processor.getAnnotation(method, PATCH.class).value(), wrap(JsonSchemaResolver.resolveSchema(jsonSchema.value())));
        }
    }

    private static Middleware wrap(final JsonSchemaResolver.Schema schema) {
        return new Middleware() {
            @Override
            public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
                if (!com.jetdrone.vertx.yoke.json.JsonSchema.conformsSchema(request.body(), schema)) {
                    next.handle(400);
                    return;
View Full Code Here

    public void process(Router router, Object instance, Class<?> clazz, Field field) {
        // NOOP
    }

    private static Middleware wrap(final String[] consumes, final String[] produces) {
        return new Middleware() {
            @Override
            public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
                // we only know how to process certain media types
                if (consumes != null) {
                    boolean canConsume = false;
View Full Code Here

public class Compress extends TestVerticle {
  @Test
  public void testGzipCompress() {
    Yoke yoke = new Yoke(this);
    yoke.use(new com.jetdrone.vertx.yoke.middleware.Compress());
    yoke.use(new Middleware() {
      @Override
      public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
        request.response().end(new JsonObject().putString("hello", "world"));
      }
    });
View Full Code Here

    @Test
    public void testParam() {
        final Yoke yoke = new Yoke(this);

        yoke.use(new Router().get("/search/:from/:to", new Middleware() {
            @Override
            public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
                com.jetdrone.vertx.yoke.util.Validator validator = new com.jetdrone.vertx.yoke.util.Validator(
                    that("param:from").is(Type.DateTime),
                    that("param:to").is(Type.DateTime)
View Full Code Here

        final JsonObject json = new JsonObject().putObject("user", new JsonObject().putString("login", "paulo").putString("password", "pwd"));

        Yoke yoke = new Yoke(this);
        yoke.use(new com.jetdrone.vertx.yoke.middleware.BodyParser());
        yoke.use(new Router().post("/search/:from/:to", new Middleware() {
            @Override
            public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
                com.jetdrone.vertx.yoke.util.Validator validator = new com.jetdrone.vertx.yoke.util.Validator(
                    that("param:from").is(Type.DateTime),
                    that("param:to").is(Type.DateTime),
View Full Code Here

        final JsonObject json = new JsonObject().putObject("user", new JsonObject());

        Yoke yoke = new Yoke(this);
        yoke.use(new com.jetdrone.vertx.yoke.middleware.BodyParser());
        yoke.use(new Middleware() {
            @Override
            public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {

                com.jetdrone.vertx.yoke.util.Validator validator = new com.jetdrone.vertx.yoke.util.Validator(
                    that("body:user.?login").is(Type.String)
View Full Code Here

        final JsonObject json = new JsonObject().putObject("user", new JsonObject());

        Yoke yoke = new Yoke(this);
        yoke.use(new com.jetdrone.vertx.yoke.middleware.BodyParser());
        yoke.use(new Middleware() {
            @Override
            public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
                com.jetdrone.vertx.yoke.util.Validator validator = new com.jetdrone.vertx.yoke.util.Validator(
                    that("body:user.?login").is(Type.String)
                );
View Full Code Here

TOP

Related Classes of com.jetdrone.vertx.yoke.Middleware

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.