예제 #1
0
 @Override
 public void setSessionAttribute(final String name, final Object value) {
   Session session = req.session();
   if (value == null) {
     session.unset(name);
   } else {
     session.set(name, objToStr(value));
   }
 }
예제 #2
0
 @Override
 public Collection<Cookie> getRequestCookies() {
   return req.cookies()
       .stream()
       .map(
           c -> {
             Cookie cookie = new Cookie(c.name(), c.value().orElse(null));
             c.domain().ifPresent(cookie::setDomain);
             c.path().ifPresent(cookie::setPath);
             cookie.setHttpOnly(c.httpOnly());
             cookie.setSecure(c.secure());
             return cookie;
           })
       .collect(Collectors.toList());
 }
예제 #3
0
  private Map<String, String[]> params(final Request req) {
    ImmutableMap.Builder<String, String[]> result = ImmutableMap.<String, String[]>builder();

    req.params()
        .toMap()
        .forEach(
            (name, value) -> {
              try {
                List<String> values = value.toList();
                result.put(name, values.toArray(new String[values.size()]));
              } catch (Err ignored) {
                log.debug("ignoring HTTP param: " + name, ignored);
              }
            });
    return result.build();
  }
예제 #4
0
 @Override
 public String getRequestMethod() {
   return req.method();
 }
예제 #5
0
 @Override
 public Object getSessionAttribute(final String name) {
   Session session = req.session();
   return strToObject(session.get(name).value(null));
 }
예제 #6
0
 @Override
 public String getRequestHeader(final String name) {
   return req.header(name).value(null);
 }
예제 #7
0
 @Override
 public String getRemoteAddr() {
   return req.ip();
 }
예제 #8
0
 @Override
 public Object getSessionIdentifier() {
   return req.session().id();
 }
예제 #9
0
 @Override
 public void setRequestAttribute(final String name, final Object value) {
   req.set(name, value);
 }
예제 #10
0
 @Override
 public Object getRequestAttribute(final String name) {
   Optional<Object> attr = req.get(name);
   return attr.orElse(null);
 }
예제 #11
0
 @Override
 public String toString() {
   return req.toString();
 }
예제 #12
0
 @Override
 public String getFullRequestURL() {
   return getScheme() + "://" + getServerName() + ":" + getServerPort() + req.path();
 }
예제 #13
0
 @Override
 public String getScheme() {
   return req.secure() ? "https" : "http";
 }
예제 #14
0
 @Override
 public int getServerPort() {
   return req.port();
 }
예제 #15
0
 @Override
 public String getServerName() {
   return req.hostname();
 }