示例#1
0
 @Override
 public void start() throws Exception {
   vertx
       .createHttpServer()
       .requestHandler(
           request -> {
             if (request.method().toString().equals("GET")) {
               if (request.path().equals("") || request.path().equals("/")) {
                 request
                     .response()
                     .putHeader("content-type", "text/html")
                     .end("Welcome to cmucchackers!");
               } else if (request.path().equals("/q2")) {
                 MultiMap queries = request.params();
                 request
                     .response()
                     .putHeader("content-type", "text/html; charset=utf-8")
                     .end(query(queries.get("userid"), queries.get("tweet_time")));
               } else {
                 request.response().putHeader("content-type", "text/html").end("Wrong query!");
               }
             }
           })
       .listen(80);
 }
 protected Map<String, String[]> getParams(MultiMap params) {
   Map<String, String[]> response = new HashMap<>();
   for (String name : params.names()) {
     response.put(name, params.getAll(name).toArray(new String[0]));
   }
   return response;
 }
  @Override
  public String getFormattedValue(final Map<String, Object> values) {

    final MultiMap headers =
        Mode.INCOMING.equals(this.mode)
            ? (MultiMap) values.get("requestHeaders")
            : (MultiMap) values.get("responseHeaders");

    if (headers.contains(this.identifier)) {
      return headers.get(this.identifier);
    } else {
      return "-";
    }
  }
示例#4
0
 @Override
 public String getTrailer(String trailerName) {
   return trailers.get(trailerName);
 }