Package org.vertx.java.core.http

Examples of org.vertx.java.core.http.RouteMatcher


public class RouteMatchExample extends Verticle {

  public void start() {

    RouteMatcher rm = new RouteMatcher();

    rm.get("/details/:user/:id", new Handler<HttpServerRequest>() {
      public void handle(HttpServerRequest req) {
        req.response().end("User: " + req.params().get("user") + " ID: " + req.params().get("id"));
      }
    });

    // Catch all - serve the index page
    rm.getWithRegEx(".*", new Handler<HttpServerRequest>() {
      public void handle(HttpServerRequest req) {
        req.response().sendFile("route_match/index.html");
      }
    });

View Full Code Here


    startClient();
  }

  public void start() {

    RouteMatcher routeMatcher = new RouteMatcher();

    // HTTP server
    HttpServer httpServer = vertx.createHttpServer();
    httpServer.requestHandler(routeMatcher);
View Full Code Here

public class BitcoinServerVerticle extends Verticle {

  @Override
  public void start() throws Exception {

    RouteMatcher routeMatcher = new RouteMatcher();
    routeMatcher.get("/", new Handler<HttpServerRequest>() {
      @Override
      public void handle(HttpServerRequest request) {
        request.response.sendFile("webroot/index.html");
      }
    });
    routeMatcher.getWithRegEx("(\\/.*\\.(js|css|png))", new Handler<HttpServerRequest>() {
      @Override
      public void handle(HttpServerRequest request) {
        request.response.sendFile("webroot" + request.params().get("param0"));
      }
    });
View Full Code Here

public class RouteMatchExample extends Verticle {

  public void start() {

    RouteMatcher rm = new RouteMatcher();

    rm.get("/details/:user/:id", new Handler<HttpServerRequest>() {
      public void handle(HttpServerRequest req) {
        req.response.end("User: " + req.params().get("user") + " ID: " + req.params().get("id"));
      }
    });

    // Catch all - serve the index page
    rm.getWithRegEx(".*", new Handler<HttpServerRequest>() {
      public void handle(HttpServerRequest req) {
        req.response.sendFile("route_match/index.html");
      }
    });

View Full Code Here

        // Init jersey handler
        jerseyHandler.init(configurator);

        // Set request handler for the baseUri
        RouteMatcher rm = new RouteMatcher();
        server.requestHandler(rm);
        // regex pattern will be: "^base_path/.*"
        String pattern = "^" + jerseyHandler.getBaseUri().getPath() + ".*";
        rm.all(pattern, jerseyHandler);

        // Add any additional routes if handler is provided
        if (routeMatcherHandler != null) {
            routeMatcherHandler.handle(rm);
        }
View Full Code Here

        // Init jersey handler
        jerseyHandler.init(configurator);

        // Set request handler for the baseUri
        RouteMatcher rm = new RouteMatcher();
        server.requestHandler(rm);
        // regex pattern will be: "^base_path/.*"
        String pattern = "^" + jerseyHandler.getBaseUri().getPath() + ".*";
        rm.all(pattern, jerseyHandler);

        // Add any additional routes if handler is provided
        if (routeMatcherHandler != null) {
            routeMatcherHandler.handle(rm);
        }
View Full Code Here

    this.config = new JsonObject();
    this.config.putString("namespace", "/socket.io");
    this.manager = new Manager(this.vertx, httpServer);
    this.httpServer = httpServer;

    this.rm = new RouteMatcher();
    rm.noMatch(this.httpServer.requestHandler());
    httpServer.requestHandler(rm);

    setupRequestMatcher();
  }
View Full Code Here

    this.httpServer.requestHandler(new CorsHandler(getHttpHandler()));
    this.sockServer.installApp(new JsonObject().putString("prefix", "/socket"), new SockJSHandler());
  }
 
  private Handler<HttpServerRequest> getHttpHandler() {
    RouteMatcher matcher = new RouteMatcher();
   
    matcher.get("/", new Handler<HttpServerRequest>() {
      public void handle(HttpServerRequest request) {
        request.response.end("This is the SpringOne Push Messaging Service");
      }
    });
   
    matcher.post("/messages/:topic/", new Handler<HttpServerRequest>() {
      public void handle(final HttpServerRequest request) {
        final String topic = request.params().get("topic");
        request.bodyHandler(new Handler<Buffer>(){
          public void handle(Buffer body) {
            JsonObject message =
                new JsonObject().putString("topic", topic).
                putObject("message", new JsonObject(body.toString()));
            System.out.println("Publishing message: "+message.toString());
            vertx.eventBus().publish(RabbitService.PUBLISH, message);
            request.response.end("ok");
          }
        });
      }
    });
   
    matcher.post("/subscriptions/:bindingKey/", new Handler<HttpServerRequest>(){
      public void handle(final HttpServerRequest request) {
        final String bindingKey = request.params().get("bindingKey");
        request.bodyHandler(new Handler<Buffer>(){
          public void handle(Buffer body) {
           
View Full Code Here

        httpServer.listen(port, host);
        container.logger().info("Started VertxSimplePushServer on host [" + host + "] port [" + port + "]");
    }

    private void setupHttpNotificationHandler(final HttpServer httpServer, final SimplePushServer simplePushServer) {
        final RouteMatcher rm = new RouteMatcher();
        final String endpointUrlPrefix = simplePushServer.config().endpointPrefix();
        rm.put(endpointUrlPrefix + "/:endpoint", new HttpNotificationHandler(simplePushServer, vertx, container));
        httpServer.requestHandler(rm);
    }
View Full Code Here

    final CompletableFuture<Void> future = new CompletableFuture<>();
    if (server == null) {
      server = vertx.createHttpServer();
    }

    RouteMatcher routeMatcher = new RouteMatcher();
    routeMatcher.post("/:command", new Handler<HttpServerRequest>() {
      @Override
      public void handle(final HttpServerRequest request) {
        request.bodyHandler(new Handler<Buffer>() {
          @Override
          @SuppressWarnings({"unchecked", "rawtypes"})
View Full Code Here

TOP

Related Classes of org.vertx.java.core.http.RouteMatcher

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.