RequestImpl implements Request { @Override public Optional<String> cookie(CookieSpec spec) { if (cookies == null) return Optional.empty(); return Optional.ofNullable(cookies.get(spec.name)); } RequestImpl(HttpServerExchange exchange, RequestBeanReader reader); @Override String requestURL(); @Override String scheme(); @Override String hostName(); @Override String path(); @Override String clientIP(); @Override Optional<String> cookie(CookieSpec spec); @Override Session session(); @Override HTTPMethod method(); @Override Optional<String> header(String name); @Override String pathParam(String name); @Override Map<String, String> queryParams(); @Override Map<String, String> formParams(); @Override Map<String, MultipartFile> files(); @Override Optional<byte[]> body(); @Override T bean(Class<T> beanClass); final PathParams pathParams; public Session session; }
@Test void cookie() { CookieSpec spec = new CookieSpec("name"); assertThat(request.cookie(spec)).isNotPresent(); request.cookies = Map.of("name", "value"); assertThat(request.cookie(spec)).get().isEqualTo("value"); }