Package com.jetdrone.vertx.yoke

Examples of com.jetdrone.vertx.yoke.Middleware


        paramProcessors.put(paramName, handler);
        return this;
    }

    public Router param(@NotNull final String paramName, @NotNull final Pattern regex) {
        return param(paramName, new Middleware() {
            @Override
            public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
                if (!regex.matcher(request.params().get(paramName)).matches()) {
                    // Bad Request
                    next.handle(400);
View Full Code Here


                new AsyncIterator<String>(binding.paramNames) {
                    @Override
                    public void handle(String param) {
                        if (hasNext()) {
                            params.set(param, m.group(param));
                            final Middleware paramMiddleware = paramProcessors.get(param);
                            if (paramMiddleware != null) {
                                // do not block main loop
                                vertx.runOnContext(new Handler<Void>() {
                                    @Override
                                    public void handle(Void event) {
                                        paramMiddleware.handle(request, new Handler<Object>() {
                                            @Override
                                            public void handle(Object err) {
                                                if (err == null) {
                                                    next();
                                                } else {
View Full Code Here

        return this;
    }

    private Middleware delete(final String idName) {
        return new Middleware() {
            @Override
            public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
                // get the real id from the params multimap
                final String id = request.params().get(idName);
View Full Code Here

            }
        };
    }

    private Middleware create(final String idName) {
        return new Middleware() {
            @Override
            public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
                JsonObject item = request.body();

                if (item == null) {
View Full Code Here

            }
        };
    }

    private Middleware append(final String idName) {
        return new Middleware() {
            @Override
            public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
                // get the real id from the params multimap
                final String id = request.params().get(idName);
View Full Code Here

            }
        };
    }

    private Middleware update(final String idName) {
        return new Middleware() {
            @Override
            public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
                JsonObject item = request.body();

                if (item == null) {
View Full Code Here

    private Middleware query(final String idName) {
        // range pattern
        final Pattern rangePattern = Pattern.compile("items=(\\d+)-(\\d+)");

        return new Middleware() {
            @Override
            public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
                // content negotiation
                if (request.accepts("application/json") == null) {
                    // Not Acceptable (we only talk json)
View Full Code Here

            }
        };
    }

    private Middleware read(final String idName) {
        return new Middleware() {
            @Override
            public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
                // content negotiation
                if (request.accepts("application/json") == null) {
                    // Not Acceptable (we only talk json)
View Full Code Here

public class Issue130 extends TestVerticle {

    @Test
    public void testRegEx() {
        Yoke yoke = new Yoke(this);
        yoke.use(new com.jetdrone.vertx.yoke.middleware.Router().get(Pattern.compile("^/url/.*"), new Middleware() {
            @Override
            public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
                request.response().end("OK");
            }
        }));
View Full Code Here

    }

    @Test
    public void testRegExEscaped() {
        Yoke yoke = new Yoke(this);
        yoke.use(new com.jetdrone.vertx.yoke.middleware.Router().get(Pattern.compile("^/url/.*"), new Middleware() {
            @Override
            public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
                request.response().end("OK");
            }
        }));
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.